Skip to content

Instantly share code, notes, and snippets.

View itamar's full-sized avatar

Itamar Yunger itamar

View GitHub Profile
@itamar
itamar / gist:ce0a5446906919ac7b3d92e3e68dc408
Created July 19, 2018 20:32
Hide Intercom launcher on mobile devices
isMobile = () ->
if navigator.userAgent.match(/Android/i) ||
navigator.userAgent.match(/webOS/i) ||
navigator.userAgent.match(/iPhone/i) ||
navigator.userAgent.match(/iPad/i) ||
navigator.userAgent.match(/BlackBerry/i) ||
navigator.userAgent.match(/Windows Phone/i)
true
else
false
// Line #624, I needed to "reset the audioPlayers array
function profileAudioPlayers(){
audioPlayers = []
$('.provider-audio').each ...
}
// Line #236
Changed from:
$('.provider-audio__play').on('click touchstart', function(){
To:
@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");
@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 / 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 / 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 / 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 / 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 / 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 / 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);