Skip to content

Instantly share code, notes, and snippets.

; Sample supervisor config file.
[unix_http_server]
file=/tmp/supervisor.sock ; (the path to the socket file)
;chmod=0700 ; sockef file mode (default 0700)
;chown=nobody:nogroup ; socket file uid:gid owner
;username=user ; (default is no username (open server))
;password=123 ; (default is no password (open server))
;[inet_http_server] ; inet (TCP) server disabled by default
@momer
momer / example.xml
Created May 31, 2014 22:16
Solrxml unmarshal
<response>
<lst name="responseHeader">
<int name="status">0</int>
<int name="QTime">10</int>
</lst>
<arr name="filelist">
<lst>
<str name="name">segments_d</str>
<long name="size">110</long>
</lst>
111.xxx.xxx.xxx RACK1 Up Normal 658.17 MB 34.04% -9216737431043722247
222.xxx.xxx.xxx RACK1 Up Normal 309.34 KB 32.87% -9211045726435137916
333.xxx.xxx.xxx RACK1 Up Normal 309.34 KB 32.87% -9197920792308199209
package myApp;
class ImplementsDynamic
implements Dynamic<String> {
public var present:Int;
public function new() {}
}
@momer
momer / PG_auto_backup_upload_to_remote_cronjob
Last active December 14, 2015 21:58
Automagically backup & upload postgres database to a remote server at 5:45am every day.
# m h dom mon dow user command
45 5 * * * postgres pg_dumpall -l YOURDBNAME | gzip -c | ssh backup@MYBACKUPSERVER "cat | gzip /YOURDIRECTORYPATH/pg_backups/$(date +\"%Y-%m-%d:%T\")YOURFILENAME.gz"
@momer
momer / ability.rb
Last active December 15, 2015 11:18
As promised, here's the collaboration set-up I created with CanCan. I'd found the original idea through a suggestion in stack overflow (which even had some ideas for tests listed), which I then heavily adapted to my use case. Tests pass below; next steps for anyone else looking to use something like this is just implementing the fancy footwork i…
class Ability
include CanCan::Ability
def initialize(user)
user ||= User.new # IE: Guest user isn't signed in, create a user
if user.try(:is?, :admin)
can :manage, :all
elsif !user.roles.empty? && user.approved?
# include <stdio.h>
int main() {
char str[] = "Reverse me!";
int length;
for (length = 0; str[length] != '\0'; length++) {
@momer
momer / explain_analyze.sql
Last active December 16, 2015 11:29
Super Fast Random Postgres Queries
--
-- Person's unoptimized query
--
QUERY PLAN
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Seq Scan on keyword_tracked_tweets (cost=0.06..484854.06 rows=50015 width=172) (actual time=16639.692..32543.957 rows=1 loops=1)
Filter: ((id)::double precision = trunc((random() * ($1)::double precision)))
InitPlan 2 (returns $1)
-> Result (cost=0.05..0.06 rows=1 width=0) (actual time=0.045..0.047 rows=1 loops=1)
@momer
momer / MyFirstBrainfuck
Last active December 19, 2015 03:59
Continually prints 'Get Money' while incrementing the ptr ad infinitum (or at least until size of int for cell #(0))
+[ Increment ptr(0) and enter loop
>++++++++++ Increment byte at ptr(1) 10 times
[ While ptr
>+++++++ incremement ptr(2) 7 times
>++++++++++ increment ptr(3) 10 times
>+ increment ptr(4) 1 time
>+++ increment ptr(5) 3 times
<<<< - back down to ptr 1 and decrement ptr 1
]
@momer
momer / discrete_math_uccs.py
Created September 2, 2013 21:46
University of Colorado - Colorado Springs puts up a bunch of math course video lectures & more online for free. Simple script to download all of the Discrete Math lectures
import urllib
import urllib.request
def DownloadClass():
url = "http://cmes.uccs.edu/Fall2011/Math215/Videos/"
ext = ".mov"
movie_name = "Math215Lecture"
for i in range(1, 27):