Skip to content

Instantly share code, notes, and snippets.

@rauchg
rauchg / README.md
Last active January 6, 2024 07:19
require-from-twitter
@paulirish
paulirish / bling.js
Last active November 4, 2024 17:48
bling dot js
/* bling.js */
window.$ = document.querySelectorAll.bind(document);
Node.prototype.on = window.on = function (name, fn) {
this.addEventListener(name, fn);
};
NodeList.prototype.__proto__ = Array.prototype;
@devlead
devlead / AddBitbucketSlackHook
Created January 8, 2015 15:06
Rough 1min add slack hook to all or certain repos PowerShell sample
$owner = "repo owner"
$body = @{type="POST";URL="slack hook"}
$cred=Get-Credential
$repos = Invoke-RestMethod -Credential $cred -Uri 'https://api.bitbucket.org/1.0/user/repositories/'
#All repos
$repos |Where-Object {$_.owner -eq $owner} | %{$uri="https://bitbucket.org/api$($_.resource_uri)/services/";Invoke-RestMethod -Uri $uri -Body $body -Method Post -Credential $cred}
#Filter repos
$repos |Where-Object {$_.owner -eq $owner -and $_.resource_uri -like "*needle*" } | %{$uri="https://bitbucket.org/api$($_.resource_uri)/services/";Invoke-RestMethod -Uri $uri -Body $body -Method Post -Credential $cred}
@staltz
staltz / introrx.md
Last active November 14, 2024 11:27
The introduction to Reactive Programming you've been missing
@fisshy
fisshy / Based on
Last active October 9, 2016 17:52
Simple image upload to image-shack using node.js
Request your API key here
http://imageshack.us/api_request/
For more information please visist
https://docs.google.com/document/d/16M3qaw27vgwuwXqExo0aIC0nni42OOuWu_OGvpYl7dE/pub
@DiegoSalazar
DiegoSalazar / validate_credit_card.js
Last active October 22, 2024 21:47
Luhn algorithm in Javascript. Check valid credit card numbers
// Takes a credit card string value and returns true on valid number
function valid_credit_card(value) {
// Accept only digits, dashes or spaces
if (/[^0-9-\s]+/.test(value)) return false;
// The Luhn Algorithm. It's so pretty.
let nCheck = 0, bEven = false;
value = value.replace(/\D/g, "");
for (var n = value.length - 1; n >= 0; n--) {
@jlong
jlong / uri.js
Created April 20, 2012 13:29
URI Parsing with Javascript
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
parser.host; // => "example.com:3000"
@ShirtlessKirk
ShirtlessKirk / luhn.js
Last active August 27, 2024 05:35
Luhn validation algorithm
/**
* Luhn algorithm in JavaScript: validate credit card number supplied as string of numbers
* @author ShirtlessKirk. Copyright (c) 2012.
* @license WTFPL (http://www.wtfpl.net/txt/copying)
*/
var luhnChk = (function (arr) {
return function (ccNum) {
var
len = ccNum.length,
bit = 1,