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
$.getScript("http://platform.twitter.com/widgets.js", function(){ | |
function handleTweetEvent(event){ | |
if (event) { | |
alert("This is a callback from a tweet") | |
} | |
} | |
twttr.events.bind('tweet', handleTweetEvent); | |
}); | |
<a href="http://twitter.com/intent/tweet?url=http://test.com;via=stack">twitter</a> |
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
/* comma-separated thousands */ | |
// if no decimals | |
function numberWithCommas(x) { | |
return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","); | |
} | |
// if more than 3 decimal places | |
function numberWithCommas(x) { | |
var parts = x.toString().split("."); |
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
### | |
# scala | |
## | |
object P extends App{ | |
def c(M:Int)={ | |
val p=collection.mutable.BitSet(M+1) | |
p(2)=true | |
(3 to M+1 by 2).map(p(_)=true) | |
for(i<-p){ | |
var j=2*i; |
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
/** | |
* Proprietary work of Alex Ehrnschwender | |
*/ | |
def sum(xs: List[Int]): Int = { | |
var i = 0 | |
if (xs.isEmpty) i else i + xs.head + sum(xs.tail) | |
} | |
def max(xs: List[Int]): Int = { |
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
zip -d ZIPfile.zip `unzip -l ZIPfile.zip | grep .DS_Store | awk '{print $4}'` |
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
/* | |
* Re-formats a number for phone call | |
* Takes (555) 555-5555 and replaces with 5555555555 | |
* To make a call from mobile use <a href="tel:XXX-XXX-XXXX"> | |
*/ | |
var raw_phoneNum = formatted_phoneNum.replace(/\)\s*|\(\s*|-/g, ''); |
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 sort_by = function(field, reverse, primer){ | |
var key = function (x) {return primer ? primer(x[field]) : x[field]}; | |
return function (a,b) { | |
var A = key(a), B = key(b); | |
return (A < B ? -1 : (A > B ? 1 : 0)) * [1,-1][+!!reverse]; | |
} | |
}; |
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
/* | |
* COOKIE HELPERS | |
*/ | |
getCookie: function(c_name) { | |
var i, x, y, ARRcookies = document.cookie.split(";"); | |
for (i = 0; i < ARRcookies.length; i++) { | |
x = ARRcookies[i].substr(0, ARRcookies[i].indexOf("=")); | |
y = ARRcookies[i].substr(ARRcookies[i].indexOf("=") + 1); | |
x = x.replace(/^\s+|\s+$/g,""); |
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
/* | |
* Encrypt private data such as authentication keys and db connection strings inside app.config | |
* or web.config of a .NET project. Import this class inside a project and call | |
* ProtectConnectionString() to encrypt and UnprotectConnectionString() to decrypt the XML data. | |
* With a standalone executable, the config file will be built alongside the exe with .config | |
* appended. Manage multiple config files for different production environments. | |
* Important: make sure the process is single-threaded for security. | |
*/ | |
using System; |
NewerOlder