Skip to content

Instantly share code, notes, and snippets.

View maartenJacobs's full-sized avatar
🏠
Working from home

Maarten Jacobs maartenJacobs

🏠
Working from home
View GitHub Profile
@maartenJacobs
maartenJacobs / RecurDirIteration
Created June 3, 2011 08:12
Simple File filtering in PHP
class IncExtFilterIterator extends FilterIterator
{
protected $_extensions;
public function __construct($path, $includeExt)
{
parent::__construct(new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path)));
$this->_extensions = $includeExt;
@maartenJacobs
maartenJacobs / HTTPObject.js
Created June 8, 2011 12:57
HTTPObject (Bulletproof) in a configobject
// As seen in Bulletproof Ajax (The warrior, not the faulty abbreviation), by Jeremy Keith
var httpObject = function(){
if(window.XMLHttpRequest){
httpObject = function(){
return new XMLHttpRequest();
};
} else if(window.ActiveXObject) {
var xhr;
try{
xhr = new ActiveXObject("Msxml2.XMLHTTP");
@maartenJacobs
maartenJacobs / baseurl.js
Created June 8, 2011 14:38
BaseUrl simulation where "admin" is your first constant part
var baseUrl = function(){
// Calculate base url by filtering on the parts
var parts = location.pathname.split('/'),
base = '',
i,
max;
for (i = 0, max = parts.length; i < max; i++) {
if(parts[i] === 'admin'){
break;
} else if(parts[i] === ''){
@maartenJacobs
maartenJacobs / gist:1424084
Created December 2, 2011 17:28
Viewing of content type restriction
<?php
/**
* Implements hook_menu_alter().
*/
function module_menu_alter(&$items) {
$old_callback = $items['node/%node']['access callback'];
$old_args = $items['node/%node']['access arguments'];
// Overrides the access callback to remove access to note content
$items['node/%node']['access callback'] = '_note_node_view_access';
@maartenJacobs
maartenJacobs / hop.sh
Created February 17, 2012 16:16
Hop-update branches
#!/bin/bash
end_branch=$1
# Get currently active branch
active_branch=$(g branch | ack '\* ([A-Za-z0-9]+)' | cut -d' ' -f 2)
# Stash current changes for rebase pull
stash_result=$(git stash)
@maartenJacobs
maartenJacobs / strategy_storage.js
Created May 16, 2012 15:56 — forked from stugoo/gist:2711536
session / local storage switcher
var shortlistings = (function() {
"use strict";
var exports = {
disableSession: disableSession,
enableSession: enableSession,
set: set
},
session_storage_method = window.sessionStorage,
local_storage_method = window.localStorage,
setInterval(function () {
console.log('A second has passed. Time to get to work.');
}, 1000);
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure(2) do |config|
config.vm.box = "ubuntu/trusty64"
config.vm.network "forwarded_port", guest: 80, host: 8080
config.vm.provider "virtualbox" do |vb|
vb.memory = 1024
vb.cpus = 2
end
@maartenJacobs
maartenJacobs / convert_to_verified_routes.ex
Created April 5, 2023 12:43 — forked from andreaseriksson/convert_to_verified_routes.ex
This is a mix task for converting old Phoenix routes to new verified routes
defmodule Mix.Tasks.ConvertToVerifiedRoutes do
@shortdoc "Fix routes"
use Mix.Task
@regex ~r/(Routes\.)(.*)_(path|url)\(.*?\)/
@web_module MyAppWeb
def run(_) do
Path.wildcard("lib/**/*.*ex")
@maartenJacobs
maartenJacobs / live_phone.css
Created November 29, 2023 11:01
Live Phone CSS converted to Tailwind
/**
Include this file instead of importing the CSS file from deps/
*/
/* Top level container for live phone components. */
.live_phone {
@apply relative flex rounded-[5px] border-[1px] border-solid border-[#ddd] bg-white;
@apply focus-within:shadow-[0_0_5px_blue];
}