Skip to content

Instantly share code, notes, and snippets.

View marcesher's full-sized avatar

Marc Esher marcesher

View GitHub Profile
@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 / 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: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 / 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 / classpath.xml
Created November 29, 2012 12:06
database migration automation example
<!-- jtds.jar, used to connect to SQL Server, is in 'lib' -->
<path id="project.classpath">
<fileset dir="lib">
<include name="*.jar" />
</fileset>
</path>
@marcesher
marcesher / state_is_a_bug.txt
Created November 9, 2012 14:29
State Is a Bug : Questions
Joe, thanks for responding.
I'm most interested in what are perhaps pedestrian issues, but they're issues (for me) nonetheless. You mentioned "outsourcing" session management... where can I read more on that?
Take the simple case of: I'm a user on your system. I'm logged in. I'm doing things. The server I'm on disappears while the screen I'm reading is currently loading.
What happens? Do I see an error? Am I sent to a new machine, with all my session state in tact, and the screen I was reading simply reloads?
Or take perhaps a different architecture where a machine isn't brought down until all its users have been successfully moved to other servers. For example, perhaps our configuration is such that we have N instances, and we do a rolling code push to those instances. User A is on Server 5, which has the old code. We need to get that user to Server 2, which has the new code, along with all of his state. Once all users are off of Server 5, the deploy then moves to Server 5 as well and then Server 5 is b
@marcesher
marcesher / famine.sql
Created October 16, 2012 16:05
a commentary
During the great alphabet famine of two thousand aught six, column names were abbreviated to near-non-readability. In order to automate tests of [newsystem] reports against [oldsystem] reports, we're retaining those column names here. You're welcome.
@marcesher
marcesher / ZipCodeService_method.groovy
Created September 12, 2012 20:57
mongodb examples
def populationByState(){
return zipcodes().aggregate(
[ $group :
[ _id : [ state : '$state', city : '$city' ], pop : [ $sum : '$pop' ] ]
],
[ $group :
[ _id : '$_id.state', avgCityPop : [ $avg : '$pop' ] ]
],
[ $sort: ['avgCityPop' : -1] ]
).results()
@marcesher
marcesher / ChatService.groovy
Created September 4, 2012 22:41
websocket broadcaster example
class ChatService {
static transactional = false
static atmosphere = [mapping: '/atmosphere/chat']
.....
@marcesher
marcesher / ChatService.groovy
Created August 20, 2012 10:06
websocket chat example
class ChatService {
static transactional = false
static atmosphere = [mapping: '/atmosphere/chatty']