Skip to content

Instantly share code, notes, and snippets.

Avatar

Tobias tordans

View GitHub Profile
@rob-murray
rob-murray / console_out.rb
Created Jan 9, 2015
Update a Rails readonly field
View console_out.rb
2.1.5 :020 > User
=> User(id: integer, name: string, email: string, created_at: datetime, updated_at: datetime)
2.1.5 :021 > User.create(name: 'rob', email: 'orb@example.com')
(0.1ms) begin transaction
SQL (1.0ms) INSERT INTO "users" ("name", "email", "created_at", "updated_at") VALUES (?, ?, ?, ?) [["name", "rob"], ["email", "orb@example.com"], ["created_at", "2015-01-09 08:50:31.962223"], ["updated_at", "2015-01-09 08:50:31.962223"]]
(0.8ms) commit transaction
=> #<User id: 2, name: "rob", email: "orb@example.com", created_at: "2015-01-09 08:50:31", updated_at: "2015-01-09 08:50:31">
2.1.5 :022 > User.first
User Load (0.3ms) SELECT "users".* FROM "users" ORDER BY "users"."id" ASC LIMIT 1
=> #<User id: 2, name: "rob", email: "orb@example.com", created_at: "2015-01-09 08:50:31", updated_at: "2015-01-09 08:50:31">
@AndiH
AndiH / README.md
Last active Aug 29, 2015
Graph generation for a bunch of pictures
View README.md

Here are Python scripts to generate and analyze and print data of a bunch of pictures. I made them for our scout campsite, at which we generated 1700 pictures with five photographers in the summer of 2014.

You find a write-up in German here: http://static.andreasherten.de/2014/09/06/campsite-pictures.html

The scripts are a bit messy. I'm sorry for that.

Files

  • picStats.py gathers information and saves them into a JSON file
  • createPictureGraphs.py reads in this information, does some resorting and stuff, and uses pyplot (with prettyplotlib) to display them
  • compareYears.py looks at three different JSON files of three different years and display some graph.
@pmeenan
pmeenan / user-timing-rum.js
Last active Jun 16, 2020
Support routine for adding W3C user timing events to a site. Includes some basic polyfill support for browsers that don't support user timing or navigation timing (though the start time for non-navigation timing support could be improved with IE < 9 to use IE's custom start event).
View user-timing-rum.js
// Support routines for automatically reporting user timing for common analytics platforms
// Currently supports Google Analytics, Boomerang and SOASTA mPulse
// In the case of boomerang, you will need to map the event names you want reported
// to timer names (for mPulse these need to be custom0, custom1, etc) using a global variable:
// rumMapping = {'aft': 'custom0'};
(function() {
var wtt = function(n, t, b) {
t = Math.round(t);
if (t >= 0 && t < 3600000) {
// Google Analytics
@marians
marians / database.sql
Created Jul 27, 2011
Snapshot of the script I wrote to generate http://vimeo.com/26157684
View database.sql
CREATE TABLE `stations` (
`id` varchar(9) COLLATE latin1_general_ci NOT NULL,
`postalcode` varchar(5) COLLATE latin1_general_ci NOT NULL,
`name` varchar(255) COLLATE latin1_general_ci NOT NULL,
`longitude` decimal(5,2) NOT NULL,
`latitude` decimal(5,2) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci COMMENT='BfS Sensor Stations';
CREATE TABLE `values_2h` (
@gr2m
gr2m / jquery.focus_select.js
Created May 1, 2011
$('input, select').focus_select() will focus the <select> and select the <input>. select does not work on <select>s
View jquery.focus_select.js
jQuery.fn.focus_select = function() {
return this.each(function(){
var $this = jQuery(this);
if ( $this.is('select') ) {
$this.focus()
} else {
$this.select()
}
})
}
@schacon
schacon / gist:942899
Created Apr 26, 2011
delete all remote branches that have already been merged into master
View gist:942899
$ git branch -r --merged |
grep origin |
grep -v '>' |
grep -v master |
xargs -L1 |
awk '{split($0,a,"/"); print a[2]}' |
xargs git push origin --delete
View make_compact_js_css.pl
#!/usr/bin/perl
# This script concatenates and minifies a given set of CSS and JavaScript files
# so that only one JS and one CSS file are the result.
#
# In order to make it work for your project, configure the path settings and the
# file names both for input and output files.
#
# by Marian Steinbach <marian@sendung.de>