Skip to content

Instantly share code, notes, and snippets.

Stephen Pike scpike

Block or report user

Report or block scpike

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View catsqlpipes.js
(function(x) {
if (x.length > 0) {
return "'(" + x.split("\n").join("|") + ")'"
}
})
View echo.js
(function(x) {
return x;
})
View atoi.rb
# String#to_i converts a string to an integer:
# "42".to_i # 42
# "0".to_i # 0
#
# Implement a new function atoi(s) which takes a string and converts it to an integer without using to_i:
# atoi("42") # 42
# atoi("0") # 0
#
def atoi(s)
-1 # not the right answer
@scpike
scpike / README.md
Created Mar 2, 2016 — forked from renchap/README.md
One-line certificate generation/renews with Letsencrypt and nginx
View README.md

Prerequisites : the letsencrypt CLI tool

This method allows your to generate and renew your Lets Encrypt certificates with 1 command. This is easily automatable to renew each 60 days, as advised.

You need nginx to answer on port 80 on all the domains you want a certificate for. Then you need to serve the challenge used by letsencrypt on /.well-known/acme-challenge. Then we invoke the letsencrypt command, telling the tool to write the challenge files in the directory we used as a root in the nginx configuration.

I redirect all HTTP requests on HTTPS, so my nginx config looks like :

server {
@scpike
scpike / dedupe.js
Last active Nov 23, 2015
deduplicate some names
View dedupe.js
// http://stackoverflow.com/questions/18233874/get-all-the-combinations-of-n-elements-of-multidimensional-array
function getCombinations(arr, n) {
if(n == 1)
{
var ret = [];
for(var i = 0; i < arr.length; i++)
{
ret.push([arr[i]]);
}
return ret;
View remove_blanks.rb
-> (x) do
x.split("\n").reject { |l| l.to_s.strip == '' }.join("\n")
end
View sortlines.rb
-> (s) do
s.split("\n").sort.join("\n")
end
View tokens.js
(function (x) {
var tokens = x.split(/[\s]/mi);
var occ = {};
tokens.forEach(function(tok) {
var clean = tok.toLowerCase().trim().replace(/[^\w\d\/]/, '');
if (occ[clean]) {
occ[clean] += 1;
} else {
occ[clean] = 1;
}
@scpike
scpike / catsql.js
Created Oct 20, 2015
Combine a list of numbers for a big `in ()` statement
View catsql.js
(function(x) {
if (x.length > 0) {
return "(" + x.split("\n").join(',') + ")"
}
})
@scpike
scpike / sortlines.js
Last active Oct 17, 2015
Sorts the lines in your input.
View sortlines.js
(function(x) {
return x.split("\n").sort().join("\n");
})
You can’t perform that action at this time.