This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
LOCAL="/path/to/local/dir" | |
while true | |
do | |
inotifywait -r $LOCAL | |
rsync -avL --progress --exclude-from rsync_exclude.list -e "ssh -i /path/to/id_rsa" /path/to/local/dir username@host:~/ | |
done |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Element.prototype.remove = function() { | |
this.parentElement.removeChild(this); | |
}; | |
NodeList.prototype.remove = HTMLCollection.prototype.remove = function() { | |
for (var i = 0, len = this.length; i < len; i++) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Element.prototype.toggleVisibility = function () { | |
this.style.visibility = (this.style.visibility == '' || this.style.visibility == 'visible') ? 'hidden' : 'visible'; | |
return this; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def lnrss(s): | |
""" | |
Returns the length of longest substring of input string with no repeated letter. | |
Assumes input string to be in lower case and ignores any other characters. | |
""" | |
l = 0 | |
for i in range(len(s)): | |
for j in range(len(s) - i): | |
ss = s[j:j+i+1] | |
if (not has_rep(ss)) and len(ss)>=l: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from selenium import webdriver | |
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities | |
from bs4 import BeautifulSoup | |
# edit desired capabilities | |
dcap = dict(DesiredCapabilities.PHANTOMJS) | |
dcap["phantomjs.page.settings.userAgent"] = ( | |
"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/53 " | |
"(KHTML, like Gecko) Chrome/15.0.87" | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var array1 = [1,2,3,4,5]; | |
var array2 = [1,2,3,4,5,6,7,8,9,10]; | |
var union = []; | |
set = {}; | |
for(var j = 0; j < array1.length; j++){ | |
set[array1[j]] = true; | |
} | |
for(var k = 0; k < array2.length; k++){ | |
set[array2[k]] = true; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function foo(){ | |
var callback = arguments[0] || function(){return "do nothing"}; | |
var options = arguments[1] || {}; | |
return [callback(), options.a || "no A", options.b || "no B", this]; | |
} | |
// try these out to understand how to use apply and what it means to write functions which might be called in this way | |
foo(null, {a:1, b:2}); | |
foo.apply("apples", [function(){return "do something"}, {a:1, b:2}]); |
OlderNewer