Awesome PHP has been relocated permanently to its own Github repository. No further updates will made to this gist.
Please open an issue for any new suggestions.
/* Tiny web server in Golang for sharing a folder | |
Copyright (c) 2010-2014 Alexis ROBERT <[email protected]> | |
Contains some code from Golang's http.ServeFile method, and | |
uses lighttpd's directory listing HTML template. */ | |
package main | |
import "net/http" | |
import "net/url" |
Awesome PHP has been relocated permanently to its own Github repository. No further updates will made to this gist.
Please open an issue for any new suggestions.
Latency Comparison Numbers (~2012) | |
---------------------------------- | |
L1 cache reference 0.5 ns | |
Branch mispredict 5 ns | |
L2 cache reference 7 ns 14x L1 cache | |
Mutex lock/unlock 25 ns | |
Main memory reference 100 ns 20x L2 cache, 200x L1 cache | |
Compress 1K bytes with Zippy 3,000 ns 3 us | |
Send 1K bytes over 1 Gbps network 10,000 ns 10 us | |
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD |
doInstall <- TRUE # Change to FALSE if you don't want packages installed. | |
toInstall <- c("ggplot2") | |
if(doInstall){install.packages(toInstall, repos = "http://cran.r-project.org")} | |
lapply(toInstall, library, character.only = TRUE) | |
# Generate some randomly-distributed data | |
nObs <- 5000 | |
myData <- data.frame(X = rnorm(nObs), Y = rnorm(nObs)) | |
nClusters <- 7 # Cluster it | |
kMeans <- kmeans(myData, centers = nClusters) |
package main | |
import ( | |
"fmt" | |
"time" | |
) | |
// Suggestions from golang-nuts | |
// http://play.golang.org/p/Ctg3_AQisl |
// A small utility to resize images inside folder (including subfolder). | |
package main | |
import ( | |
"fmt" | |
"flag" | |
"math" | |
"os" | |
"io/ioutil" | |
"os/exec" |
# Key considerations for algorithm "RSA" ≥ 2048-bit
openssl genrsa -out server.key 2048
# Key considerations for algorithm "ECDSA" ≥ secp384r1
# List ECDSA the supported curves (openssl ecparam -list_curves)
import os, sys | |
import subprocess, signal | |
import time | |
from bs4 import BeautifulSoup | |
import selenium as sl | |
from selenium.webdriver import Firefox, FirefoxProfile | |
URL = 'https://www.usefulservice.com/' |
public class NamedParamStatement { | |
public NamedParamStatement(Connection conn, String statementWithNames) throws SQLException { | |
Pattern findParametersPattern = Pattern.compile("(?<!')(:[\\w]*)(?!')"); | |
Matcher matcher = findParametersPattern.matcher(statementWithNames); | |
while (matcher.find()) { | |
fields.add(matcher.group().substring(1)); | |
} | |
prepStmt = conn.prepareStatement(statementWithNames.replaceAll(findParametersPattern.pattern(), "?")); | |
} |