Skip to content

Instantly share code, notes, and snippets.

View marcesher's full-sized avatar

Marc Esher marcesher

View GitHub Profile
@marcesher
marcesher / notes.txt
Last active December 10, 2015 23:29
Notes and questions about static assets in django
my notes on django static assets during development. This is not related to collectstatic or configuring the webserver:
1) created new /static/ directory under 'mysite'
2) put some stuff in there... css, images
How to include in templates:
1) Using the {{STATIC_URL}} seting
--requires Zero additional configuration unlike {% static "blah.css" %}
@marcesher
marcesher / gist:5151652
Created March 13, 2013 12:33
regex search/replace for django direct_to_template and redirect_to upgrade in 1.5
direct_to_template, \{'template':(.*?)}
TemplateView.as_view(template_name=$1)
redirect_to, \{'url': (.*?)}
RedirectView.as_view(url=$1)
@marcesher
marcesher / replset_port_change.js
Last active December 22, 2015 15:49
quickie: change mongo ports in repl set config
use local
cfg = db.system.replset.findOne()
cfg.members.forEach( function(m) { var tmp = m.host.replace(27018,12345); print(tmp); m.host = tmp; } )
cfg
db.system.replset.update({"_id":cfg['_id']}, cfg)
db.system.replset.findOne()
@marcesher
marcesher / gist:7168642
Last active December 27, 2022 10:29
install 7zip on linux
In this case, in AWS Linux:
yum-config-manager --enable epel
yum install -y p7ip
cp /usr/bin/7za /usr/bin/7z
7z
@marcesher
marcesher / go_tour_slice_exercise.go
Created December 29, 2013 13:02
simple solution to Go tour slide 35, exercise on slices. This prints a blue gradient
package main
import (
"code.google.com/p/go-tour/pic"
"math"
)
func Pic(dx, dy int) [][]uint8 {
p := make([][] uint8, dy)
for i :=0; i < dy; i++ {
@marcesher
marcesher / slightly_better_wordcount.go
Last active January 1, 2016 16:29
ugly-ass solution for Go wordcount map exercise
package main
import (
"code.google.com/p/go-tour/wc"
"strings"
)
func WordCount(s string) map[string]int {
m := make(map [string] int)
for _, v := range strings.Fields(s) {
@marcesher
marcesher / go_tour_http_handle_exercise.go
Created January 8, 2014 11:58
simple solution to go tour exercise for http.Handle
package main
import (
"fmt"
"net/http"
)
type String string
type Hello struct {
Greeting string
@marcesher
marcesher / rot13.go
Created January 8, 2014 12:40
go tour rot13 exercise I imagine the strings.ToLower version is much slower. experimenting is all.
package main
import (
"io"
"os"
"strings"
)
type rot13Reader struct {
r io.Reader
@marcesher
marcesher / pig.log
Created February 4, 2014 12:55
ye olde stack
worker-11
at java.lang.String.intern()Ljava/lang/String; (Native Method)
at clojure.lang.Symbol.intern(Ljava/lang/String;)Lclojure/lang/Symbol; (Symbol.java:62)
at clojure.lang.Keyword.intern(Ljava/lang/String;)Lclojure/lang/Keyword; (Keyword.java:53)
at clojure.core$keyword.invoke(Ljava/lang/Object;)Ljava/lang/Object; (core.clj:574)
at cfpb.qu.data$get_data_table$fn__4180$fn__4181.invoke(Ljava/lang/Object;)Ljava/lang/Object; (data.clj:176)
at clojure.core$map$fn__4207.invoke()Ljava/lang/Object; (core.clj:2485)
at clojure.lang.LazySeq.sval()Ljava/lang/Object; (LazySeq.java:42)
at clojure.lang.LazySeq.seq()Lclojure/lang/ISeq; (LazySeq.java:60)
at clojure.lang.ChunkedCons.chunkedNext()Lclojure/lang/ISeq; (ChunkedCons.java:59)
@marcesher
marcesher / gist:9863995
Created March 29, 2014 22:21
goimports_if_go.sh
#!/bin/sh
if [[ $1 == *.go ]]
then
goimports -w $1
fi