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 newid() { | |
const base = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"; // base58 | |
const size = 11; | |
let id = new Uint8Array(size); | |
crypto.getRandomValues(id); | |
let result = ""; | |
for (let i = 0; i < size; 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
// Open form and submit enquire for `rego` | |
function getInfo(rego) { | |
horseman | |
.userAgent('Mozilla/5.0 (Windows NT 6.1; WOW64; rv:27.0) Gecko/20100101 Firefox/27.0') | |
.open(url) | |
.type('#registration-number-ctrl input[type=text]', rego) | |
.click('.btn-holder input') | |
.waitForSelector('.ctrl-holder.ctrl-readonly') | |
.html() | |
.then(function(body) { |
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
// SCRIPT | |
#!/bin/bash | |
dd if=/dev/urandom bs=1M count=1 of=somerandom | |
for i in $(seq 1 1000) | |
do | |
thisblock=$(shuf -i 0-63999 -n 1) | |
sudo dd if=somerandom of=/dev/mmcblk0 bs=1M seek=$thisblock | |
sudo sync | |
sudo dd if=/dev/mmcblk0 skip=$thisblock bs=1M count=1 | diff - somerandom |
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 watermarkImage(elemImage, text) { | |
// Create test image to get proper dimensions of the image. | |
var testImage = new Image(); | |
testImage.onload = function() { | |
var h = testImage.height, w = testImage.width, img = new Image(); | |
// Once the image with the SVG of the watermark is loaded... | |
img.onload = function() { | |
// Make canvas with image and watermark | |
var canvas = Object.assign(document.createElement('canvas'), {width: w, height: h}); | |
var ctx = canvas.getContext('2d'); |
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
DELETE test | |
PUT test/test/1 | |
{"make":{"id":12,"name":"fiat"},"model":{"id":121,"name":"strada"}} | |
PUT test/test/2 | |
{"make":{"id":12,"name":"fiat"},"model":{"id":122,"name":"palio"}} | |
PUT test/test/3 | |
{"make":{"id":12,"name":"fiat"},"model":{"id":123,"name":"ka"}} | |
PUT test/test/4 | |
{"make":{"id":12,"name":"fiat"},"model":{"id":124,"name":"uno"}} |
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
import Control.Exception | |
import Control.Monad | |
import Control.Monad.IO.Class | |
import Data.ByteString.Lazy (ByteString) | |
import Data.ByteString.Lazy.UTF8 (toString) | |
import Data.Function | |
import Data.Enumerator | |
import Data.List | |
import Data.Maybe |
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
-- | URL Doc : http://hackage.haskell.org/package/url-2.1.3/docs/Network-URL.html | |
module Page where | |
import Network.URL | |
import Network.Curl | |
import Text.XML.HXT.Core | |
import Text.HandsomeSoup | |
data Page = Page { | |
title :: String, |
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
<? | |
preg_replace("/&([a-z])[a-z]+;/i", "$1", htmlentities($valor)); |
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
<?php | |
$ip = '127.0.0.1'; | |
$port = '9051'; | |
$auth = 'PASSWORD'; | |
$command = 'signal NEWNYM'; | |
$fp = fsockopen($ip,$port,$error_number,$err_string,10); | |
if(!$fp) { echo "ERROR: $error_number : $err_string"; | |
return false; |
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
// rgb is a array [r, g, b] | |
function colorContrast (rgb) { | |
var r = rgb.r * 255, | |
g = rgb.g * 255, | |
b = rgb.b * 255; | |
var factor = (r * 299 + g * 587 + b * 114) / 1000; | |
return (factor >= 128) ? 'dark' : 'light'; | |
} |
NewerOlder