Skip to content

Instantly share code, notes, and snippets.

@jdolitsky
jdolitsky / web-servers.md
Created February 12, 2019 22:21 — forked from willurd/web-servers.md
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
@jdolitsky
jdolitsky / pull.go
Created December 21, 2018 21:47 — forked from cpuguy83/pull.go
package main
import (
"context"
"fmt"
"io/ioutil"
"os"
"github.com/containerd/containerd/content/local"
"github.com/containerd/containerd/images"
@jdolitsky
jdolitsky / update-golang.md
Created April 10, 2018 17:57 — forked from nikhita/update-golang.md
How to update the Go version

How to update the Go version

System: Ubuntu 14.04 (Trusty Tahr)

1. Uninstall the exisiting version

As mentioned here, to update a go version you will first need to uninstall the original version.

To uninstall, delete the /usr/local/go directory by:

@jdolitsky
jdolitsky / asymmetric.go
Last active April 9, 2018 03:48 — forked from cryptix/LICENSE
example of using JWT for http authentication in go
package main
// using asymmetric crypto/RSA keys
import (
"crypto/rsa"
"fmt"
"io/ioutil"
"log"
"net/http"
@jdolitsky
jdolitsky / README.md
Created November 11, 2015 15:20 — forked from dnozay/_Jenkins+Script+Console.md
jenkins groovy scripts collection.
var http = require("http"),
url = require("url"),
path = require("path"),
fs = require("fs")
port = process.argv[2] || 8888;
http.createServer(function(request, response) {
var uri = url.parse(request.url).pathname
, filename = path.join(process.cwd(), uri);
[program:hello]
command = python /path/hello.py --port=80%(process_num)02d
process_name = %(program_name)s-80%(process_num)02d
stdout_logfile = /path/hello-80%(process_num)02d.log
numprocs = 5
numprocs_start = 1
; tornado run port list:
; 127.0.0.1:8001 (first)
; 127.0.0.1:8002
[root@host ~]# irb
irb(main):001:0> require "/usr/lib64/ruby/site_ruby/1.8/powerpc64-linux/shadow.so" #varies by platform - check 'rpm -ql ruby-shadow' for real location.
=> true
irb(main):004:0> Shadow::Passwd.getspent()
=> #<struct Struct::PasswdEntry sp_namp="root", sp_pwdp="$1$s9SM/aIM$ATv5Gcjkd2b/G/rkddVTq0", sp_lstchg=15095, sp_min=0, sp_max=99999, sp_warn=7, sp_inact=-1, sp_expire=-1, sp_flag=-1>
(execute getspent() repeatedly, should give a new user entry each time.
irb(main):009:0> Shadow::Passwd.setspent()
=> nil
@jdolitsky
jdolitsky / api.js
Created March 13, 2013 05:50 — forked from fwielstra/api.js
/* The API controller
Exports 3 methods:
* post - Creates a new thread
* list - Returns a list of threads
* show - Displays a thread and its posts
*/
var Thread = require('../models/thread.js');
var Post = require('../models/post.js');
var http = require('http');
function processRequest(res, num, startTime) {
if (!startTime) startTime = new Date();
if (num === undefined) {
return process.nextTick(function() {
processRequest(res, 0);
});
}