Skip to content

Instantly share code, notes, and snippets.

View sourcec0de's full-sized avatar
:octocat:
Focusing

James R Qualls sourcec0de

:octocat:
Focusing
View GitHub Profile
@sourcec0de
sourcec0de / dont-store-sessions-in-redis.md
Last active August 31, 2023 07:43
Why I choose not to store sessions in redis.

Why I don't use redis as a session store

You can never rely on a system to be online 100% of the time. It's just the ephemeral nature of computing. Inevitably things break and shit happens.

My primary reasons for not using redis

  • Increased tail latency by adding network overhead (yes redis is fast but you're still using the network)
  • If you run a slow operation it will slow down all other queries (SORT, LREM, SUNION)
  • this is because redis is single threaded
@sourcec0de
sourcec0de / all_email_provider_domains.txt
Created June 13, 2023 18:21 — forked from ammarshah/all_email_provider_domains.txt
A list of all email provider domains (free, paid, blacklist etc). Some of these are probably not around anymore. I've combined a dozen lists from around the web. Current "major providers" should all be in here as of the date this is created.
0-mail.com
007addict.com
020.co.uk
027168.com
0815.ru
0815.su
0clickemail.com
0sg.net
0wnd.net
0wnd.org
@sourcec0de
sourcec0de / haproxy.cfg
Created October 18, 2016 16:04
Here's a sample WORKING haproxy config for websockets / socketio. We were able to get socketio working on an Amazon ELB with just one node, but when we added multiple nodes, we saw weird client issues. So, we decided to use HAProxy on Ubuntu 12.04 and spent significant time trying to get just the right configuration (haproxy.cfg). Note though th…
global
#debug
#daemon
log 127.0.0.1 local0
defaults
log global
option httplog
frontend unsecured *:80
@sourcec0de
sourcec0de / js_obj_getter_by_reg.js
Created April 1, 2014 13:32
Select keys from a javascript object using a regular expression. Returns an object containing only the keys that matched the expression in the original object.
var keyMatch = function(o,r){
var c = 0;
var nO = {};
Object.keys(o).forEach(function(k){
c++;
no[k] = k.match(r) ? o[k] : void 0;
});
@sourcec0de
sourcec0de / PrivateTorrent.md
Last active September 1, 2022 09:04
Host a private torrent tracker, and seed a torrent on ubuntu 12.10

Install dep, and start tracker

sudo apt-get install bittornado ctorrent
bttrack --port 6969 --dfile ~/.bttrack/dstate --logfile ~/.bttrack/tracker.log --nat_check 0 --scrape_allowed full

Now, create a torrent file

ctorrent -t -u "YOUR_SERVER_IP:6969/announce" -s new_file_name.torrent file_or_folder_for_torrent
@sourcec0de
sourcec0de / docker-compose-coreos.sh
Created November 30, 2015 19:39
Install docker compose on coreos
sudo su -
mkdir -p /opt/bin
curl -L https://github.com/docker/compose/releases/download/1.5.1/docker-compose-`uname -s`-`uname -m` > /opt/bin/docker-compose
chmod +x /opt/bin/docker-compose
@sourcec0de
sourcec0de / proxy.go
Created August 13, 2016 19:47 — forked from montanaflynn/proxy.go
Golang reverse proxy
package main
import (
"log"
"net/http"
"net/http/httputil"
)
func main() {
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
@sourcec0de
sourcec0de / install_nodejsV0.10.9.sh
Last active November 15, 2018 08:44
A Rock solid nodejs platform install script. Latest Redis, MongoDB, and NodeJS V10.9.0 tested Ubuntu 13.04 X64
#!/bin/sh
# Add MongoDB Package
echo "Add MongoDB Package"
echo "deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen" >> /etc/apt/sources.list
apt-key adv --keyserver keyserver.ubuntu.com --recv 7F0CEB10
echo "MongoDB Package completed"
# Update System
echo "System Update"
@sourcec0de
sourcec0de / ApiController.php
Created December 7, 2012 23:14
Cross Origin Resource Sharing with PHP & YII
// add this to your API controller in Yii
public function actionPreflight() {
$content_type = 'application/json';
$status = 200;
// set the status
$status_header = 'HTTP/1.1 ' . $status . ' ' . $this->_getStatusCodeMessage($status);
header($status_header);
@sourcec0de
sourcec0de / elasticsearch-geo_point-mapping.json
Last active September 13, 2018 13:44
Elastic Search geo_point Mapping Example. Geo_Point has been mapped to venue.location.coords
{
"settings": {
"number_of_shards": 1,
"mapper": {
"dynamic": false
}
},
"mappings": {
"venue": {
"properties": {