Skip to content

Instantly share code, notes, and snippets.

View louy's full-sized avatar
💭
I may be slow to respond.

Louay Akkad louy

💭
I may be slow to respond.
View GitHub Profile
@louy
louy / git-pull-all.sh
Created July 20, 2015 10:33
git pull-all
#!/bin/sh
find $PWD -type d -name .git \
| xargs -n 1 dirname \
| sort \
| while read line; do echo $line && cd $line && git pull; done
/**
* Fix element positioning when using adminbar
*/
@mixin fixed-top( $space, $property: "top", $factor: 1 ) {
#{$property}: $space * $factor;
.admin-bar & {
#{$property}: ($space + 46px) * $factor;
@media (min-width: 783px) {
#{$property}: ($space + 32px) * $factor;
}
@louy
louy / ko.subscribable.subscribechanged.js
Created July 10, 2014 02:45
Subscribe with Old and New Value for Knockout Subscribable
ko.subscribable.fn.subscribeChanged = function( callback ) {
var oldValue;
return [
this.subscribe( function( _oldValue ) {
oldValue = _oldValue;
}, this, 'beforeChange' ),
this.subscribe( function( newValue ) {
callback( newValue, oldValue );
} )
];
@louy
louy / ko.bindinghandlers.chosen.js
Created July 10, 2014 02:42
Knockout Chosen Binding Handler with Cleanup (jQuery)
ko.bindingHandlers.chosen = {
listenBindings: ['value', 'disable', 'options', 'foreach'],
init: function( element, valueAccessor, allBindings ) {
var options = ko.unwrap(valueAccessor()), $_ = $(element);
$_.chosen( $.extend( options, {
width: '100%',
} ) );
ko.computed(function() {
$.each(ko.bindingHandlers.chosen.listenBindings, function( i, binding ) {
@louy
louy / FBDownloader.iim
Last active December 28, 2015 22:49
iMacros Facebook Album Downloader. All you need to do is open the album page and run this script in loop mode with loop max equal to the count of pictures inside the album.
VERSION BUILD=8530828 RECORDER=FX
SET !ERRORIGNORE YES
TAB T=1
SET !LOOP 1
TAG POS={{!LOOP}} TYPE=A ATTR=CLASS:uiMediaThumb* EXTRACT=href
TAB OPEN
TAB T=2
URL GOTO={{!EXTRACT}}
SET !EXTRACT NULL
@louy
louy / ras.php
Created August 12, 2013 16:16
Block Spam attacks on wp registeration page.
<?php
/*
Plugin Name: Registeration Anti-Spam
Plugin URI: https://gist.github.com/louy/6212415
Description: Block Spam attacks on wp registeration page.
Author: Louy Alakkad
Version: 1.0
Author URI: http://l0uy.com/
*/
@louy
louy / .htaccess
Created July 25, 2013 22:31
Apache .htaccess geographical redirect based on CloudFlare's geo-ip headers
# add as many as you need...
SetEnvIf CF-IPCountry SY RedirectSubdomain=syria
SetEnvIf CF-IPCountry AE RedirectSubdomain=uae
SetEnvIf CF-IPCountry EG RedirectSubdomain=egypt
# Only redirect if Host is not a subdomain
SetEnvIfNoCase Host ^.+\.example\.com$ !RedirectSubdomain
# Only redirect if cookie "noredirect" doesn't exist
SetEnvIfNoCase ^Cookie$ noredirect=true !RedirectSubdomain
@louy
louy / julianday.js
Created July 11, 2013 09:07
A method to calculate Julian Day in JavaScript. Note: this is different than Julian Date
Date.prototype.julianDay = function(){
return (this / 86400000) - (this.getTimezoneOffset()/1440) + 2440587.5;
};
@louy
louy / backbone.customroute.js
Last active December 19, 2015 12:49
Custom route function for backbone to allow before and after filters.
var AppRouter = Backbone.Router.extend({
route: function(a,b,c) {
var self=this;
function _run(f) {
var g = Array.prototype.slice.apply(arguments, [1]);
if( self.before.apply(self, [a,g]) ) {
f.apply(self,g);
self.after.apply(self, [a,g])
}
}
@louy
louy / is_email.js
Created July 8, 2013 10:47
is_email function from WordPress written in Javascript
/**
* is_email function from WordPress
* written in Javascript
*
* by Louy Alakkad <me@l0uy.com>
*
* Verifies that an email is valid.
*
* Does not grok i18n domains. Not RFC compliant.
*