This file contains 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 data = ['apple', 'pear', 'orange', 'orange', 'apple', 'lime', 'lime']; | |
data | |
.filter((item, index, array) => item !== 'pear') /* Let's filter out all pears (as they are horrible!) */ | |
.reduce((total, item, index, array) => { | |
if (total.indexOf(item) === -1) total.push(item); // Only add unique items to the array (de-duplication) | |
return total; // Return the cumulative total | |
}, [] /* Initial value, can be any primitive e.g. [], boolean etc */) | |
.map((item, index, array) => item + ' juice') /* Add the word 'juice' to the end */ | |
.forEach((item, index, array) => item + ' ' + index) /* Add an index */ |
This file contains 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
<!-- Example 1: Normal Template --> | |
<script type="text/html" id="item_tmpl"> | |
<div id="<%=id%>" class="<%=(i % 2 == 1 ? " even" : "")%>"> | |
<div class="grid_1 alpha right"> | |
<img class="righted" src="<%=profile_image_url%>"/> | |
</div> | |
<div class="grid_6 omega contents"> | |
<p><b><a href="/<%=from_user%>"><%=from_user%></a>:</b> <%=text%></p> | |
</div> | |
</div> |
This file contains 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
// Long Polling (Recommened Technique - Creates An Open Connection To Server ∴ Fast) | |
(function poll(){ | |
$.ajax({ url: "server", success: function(data){ | |
//Update your dashboard gauge | |
salesGauge.setValue(data.value); | |
}, dataType: "json", complete: poll, timeout: 30000 }); | |
})(); |
This file contains 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: http://www.chromium.org/developers/design-documents/network-stack/socks-proxy | |
To configure chrome to proxy traffic through the SOCKS v5 proxy server myproxy:8080, launch chrome with these two command-line flags: | |
--proxy-server="socks5://myproxy:8080" | |
--host-resolver-rules="MAP * 0.0.0.0 , EXCLUDE myproxy" | |
The first thing to check when debugging is look at the Proxy tab on about:net-internals, and verify what the effective proxy settings are: | |
chrome://net-internals/#proxy |
This file contains 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
<?php | |
$image = imagecreatefromjpeg($_GET['src']); | |
$filename = 'images/cropped_whatever.jpg'; | |
$thumb_width = 200; | |
$thumb_height = 150; | |
$width = imagesx($image); | |
$height = imagesy($image); |
This file contains 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 isType(arg, type) { | |
type = type.charAt(0).toUpperCase() + type.substr(1); | |
return Object.prototype.toString.call(arg) == '[object ' + type + ']'; | |
} |
This file contains 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
/* JSONPath 0.8.0 - XPath for JSON | |
* | |
* Copyright (c) 2007 Stefan Goessner (goessner.net) | |
* Licensed under the MIT (MIT-LICENSE.txt) licence. | |
*/ | |
function jsonPath(obj, expr, arg) { | |
var P = { | |
resultType: arg && arg.resultType || "VALUE", | |
result: [], | |
normalize: function(expr) { |
This file contains 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
// http://stackoverflow.com/questions/7279567/how-do-i-pause-a-window-setinterval-in-javascript | |
function RecurringTimer(callback, delay) { | |
var timerId, start, remaining = delay; | |
this.pause = function() { | |
window.clearTimeout(timerId); | |
remaining -= new Date() - start; | |
}; |
This file contains 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/bash | |
# Before using please rename from post-commit.sh to post-commit | |
# Add this file to the hooks directory in the svn root folder | |
REPOS="$1" | |
REV="$2" | |
# A - Item added to repository | |
# D - Item deleted from repository | |
# U - File contents changed |
NewerOlder