Skip to content

Instantly share code, notes, and snippets.

View itamar's full-sized avatar

Itamar Yunger itamar

View GitHub Profile
@itamar
itamar / css_bp
Created February 20, 2014 00:28
CSS Best Practices
/* instead of this: */
.row#categories .block-list li#mixing {
background: white url(/assets/home/mixing.jpg) top center no-repeat;
background-size: cover;
}
.row#categories .block-list li#mastering {
background: white url(/assets/home/mastering.jpg) top center no-repeat;
background-size: cover;
}
@itamar
itamar / gist:9522496
Created March 13, 2014 05:49
application_controller - capture_referral method
before_filter :capture_referral
private
def capture_referral
session[:referral] = params[:referral] if params[:referral]
end
@itamar
itamar / export_script.js
Created March 26, 2014 02:34
Export photoshop groups to different PNG files
#target photoshop
function main(){
if(!documents.length) return;
var doc = activeDocument;
var oldPath = activeDocument.path;
for(var a=0;a<doc.layerSets.length;a++){
activeDocument.activeLayer = activeDocument.layers.getByName(doc.layerSets[a].name);
dupLayers();
var saveFile= File(oldPath +"/"+doc.layerSets[a].name +".png");
SavePNG(saveFile);
@itamar
itamar / Happy Friday !!
Last active August 29, 2015 13:57
Happy Friday !
ruby -e 'def a;10.times{puts " "*rand(79)+"*"};end;99.times{a;puts " "*34+"!! Happy Friday Batch 8 !!";a;sleep 0.1;puts "\e[2J"}'
@itamar
itamar / policy.xml
Created August 19, 2014 17:14
policy.xml example file to prevent DOS attack
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE policymap [
<!ELEMENT policymap (policy)+>
<!ELEMENT policy (#PCDATA)>
<!ATTLIST policy domain (delegate|coder|filter|path|resource) #IMPLIED>
<!ATTLIST policy name CDATA #IMPLIED>
<!ATTLIST policy rights CDATA #IMPLIED>
<!ATTLIST policy pattern CDATA #IMPLIED>
<!ATTLIST policy value CDATA #IMPLIED>
]>
@itamar
itamar / upgrade OpenSSL
Last active August 29, 2015 14:05
One command line to upgrade OpenSSL
cd /tmp && curl https://www.openssl.org/source/openssl-1.0.1i.tar.gz | tar xz && cd openssl-1.0.1i && sudo ./config && sudo make && sudo make install
@itamar
itamar / gist:29fa5a1395bbb6bac0ff
Created August 26, 2014 21:44
increase the maximum message size (Postfix)
echo "message_size_limit = 20480000" > /etc/postfix/main.cf
service postfix reload
@itamar
itamar / gist:7302230239c1076046c8
Created September 10, 2014 18:15
Best use for iCloud ever :)
Best use for iCloud ever :)
Voice memo example:
The simplest way I found that worked around iPhone's voice memo app limitation was as follows:
- In voice memo, select your audio file and share 'via email', not SMS.
- Once email app opens, you will find the selected audio file as an attachment
- Now cancel the email - and you will be given an option to save email in draft form.
- Save in draft form
@itamar
itamar / audio_file_duration.js
Created December 28, 2015 15:40
Find audio file duration
audioElement = document.createElement('audio');
audioElement.setAttribute('src', MP3_URL_GOES_HERE);
audioElement.load();
console.log('Loading audioElement');
audioElement.addEventListener('canplaythrough', function(){
console.log('audioElement Loaded');
console.log('Duration in seconds: ' + this.duration);
})
@itamar
itamar / LoadCSS.js
Created June 22, 2016 10:04
LoadCSS.js
// http://www.gotknowhow.com/articles/how-to-asynchronously-load-font-awesome-css-file
<script>
// Asynchronously load non-critical css
function loadCSS(e, t, n) { "use strict"; var i = window.document.createElement("link"); var o = t || window.document.getElementsByTagName("script")[0]; i.rel = "stylesheet"; i.href = e; i.media = "only x"; o.parentNode.insertBefore(i, o); setTimeout(function () { i.media = n || "all" }) }
// load css file async
loadCSS("//maxcdn.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.min.css");
</script>
// load css file async
loadCSS("/css/my-test.css");