This file contains 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
package main | |
import ( | |
"fmt" | |
"net/url" | |
"strings" | |
) | |
func main() { | |
s := "redis://username:[email protected]:6389/4?pool=25&process=2" |
This file contains 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
""" | |
Progress bar for rsync | |
======================== | |
Shows file progress and total progress as a progress bar. | |
Usage | |
--------- | |
Run rsync with -P and pipe into this program. Example:: |
This file contains 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
# Create a container from the mongo image, | |
# run is as a daemon (-d), expose the port 27017 (-p), | |
# set it to auto start (--restart) | |
# and with mongo authentication (--auth) | |
# Image used is https://hub.docker.com/_/mongo/ | |
docker pull mongo | |
docker run --name YOURCONTAINERNAME --restart=always -d -p 27017:27017 mongo mongod --auth | |
# Using the mongo "localhost exception" (https://docs.mongodb.org/v3.0/core/security-users/#localhost-exception) | |
# add a root user |
This file contains 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
all: lib run | |
lib: | |
g++ -shared -fPIC -o libhello.so libhello.cpp hello.cpp | |
run: | |
luajit main.lua | |
clean: | |
rm *.so |
This file contains 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
#!/bin/bash | |
# Install Spark on CentOS 7 | |
yum install java -y | |
java -version | |
yum install wget -y | |
wget http://downloads.typesafe.com/scala/2.11.7/scala-2.11.7.tgz | |
tar xvf scala-2.11.7.tgz | |
sudo mv scala-2.11.7 /usr/lib | |
sudo ln -s /usr/lib/scala-2.11.7 /usr/lib/scala |
This file contains 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
# compile | |
$ g++ zlib-example.cpp -lz -o zlib-example | |
# run | |
$ ./zlib-example | |
Uncompressed size is: 36 | |
Uncompressed string is: Hello Hello Hello Hello Hello Hello! | |
---------- |
This file contains 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
Vector = {} | |
Vector.__index = Vector | |
function Vector.__add(a, b) | |
if type(a) == "number" then | |
return Vector.new(b.x + a, b.y + a) | |
elseif type(b) == "number" then | |
return Vector.new(a.x + b, a.y + b) | |
else | |
return Vector.new(a.x + b.x, a.y + b.y) |
This file contains 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
webserver: webserver.c libuv/uv.a http-parser/http_parser.o | |
gcc -I libuv/include \ | |
-lrt -lm -lpthread -o \ | |
webserver webserver.c \ | |
libuv/uv.a http-parser/http_parser.o | |
libuv/uv.a: | |
$(MAKE) -C libuv | |
http-parser/http_parser.o: |
This file contains 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
-module(problem20). | |
-include("euler.hrl"). | |
answer() -> lists:sum(i2d(fact(100))). | |
fact(0) -> 1; | |
fact(N) -> N * fact(N-1). |
This file contains 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
#include <stdio.h> | |
#include <stdlib.h> | |
#include <pthread.h> | |
#include <unistd.h> | |
#include <curl/curl.h> | |
#define MAX_JOBS 10 | |
// | |
// Released into the public domain. |
NewerOlder