Skip to content

Instantly share code, notes, and snippets.

View nesizer's full-sized avatar

Mikkel H Madsen nesizer

  • ProLøn A/S
  • Denmark
View GitHub Profile
@mnutt
mnutt / Instrument Anything in Rails 3.md
Created September 6, 2010 06:50
How to use Rails 3.0's new notification system to inject custom log events

Instrument Anything in Rails 3

With Rails 3.0 released a few weeks ago I've migrated a few apps and I'm constantly finding useful new improvements. One such improvement is the ability to log anything in the same way that Rails internally logs ActiveRecord and ActionView. By default Rails 3 logs look slightly spiffier than those produced by Rails 2.3: (notice the second line has been cleaned up)

Started GET "/" for 127.0.0.1 at Mon Sep 06 01:07:11 -0400 2010
  Processing by HomeController#index as HTML
  User Load (0.2ms)  SELECT `users`.* FROM `users` WHERE (`users`.`id` = 3) LIMIT 1
  CACHE (0.0ms)  SELECT `users`.* FROM `users` WHERE (`users`.`id` = 3) LIMIT 1

Rendered layouts/_nav.html.erb (363.4ms)

@5thWall
5thWall / unicorn
Created February 5, 2011 22:10
/etc/init.d script for unicorn and non-rails app
#!/bin/sh
#
# init.d script for single or multiple unicorn installations. Expects at least one .conf
# file in /etc/unicorn
#
# Modified by 5thWall@gmail.com http://github.com/5thWall
# based on https://gist.github.com/504875 by http://github.com/jaygooby
#
## A sample /etc/unicorn/my_app.conf
##
@ijt
ijt / http_get.go
Last active August 23, 2021 12:37
Example of using http.Get in go (golang)
package main
import (
"fmt"
"io"
"log"
"net/http"
"os"
)
@zyxar
zyxar / exercise.tour.go
Last active April 28, 2024 17:06
tour.golang exercise solutions
/* Exercise: Loops and Functions #43 */
package main
import (
"fmt"
"math"
)
func Sqrt(x float64) float64 {
z := float64(2.)
@aisipos
aisipos / jitbit.py
Last active August 7, 2021 00:14
My solutions to jitbit's SQL interview questions:http://www.jitbit.com/news/181-jitbits-sql-interview-questions/Uses SQLAlchemy to populate a sqlite DB with random data to try out the queries with.
"""
A module to populate a DB schema using sqlalchemy for the problems on this webpage:
http://www.jitbit.com/news/181-jitbits-sql-interview-questions/
Questions and my answers:
-- List employees (names) who have a bigger salary than their boss
select e.name from Employees as e
join Employees as b on e.BossId = b.EmployeeID
where e.Salary > b.Salary
package main
import (
"fmt"
"time"
)
func main() {
t, err := time.Parse(time.RFC3339Nano, "2013-06-05T14:10:43.678Z")
if err != nil {
@christianbundy
christianbundy / random_uniques.js
Last active December 21, 2015 09:49
Generates a set of random unique integers.
// do not use this
function random_uniques(min, max, num) {
if (max-min > num) {
_result = {};
for (i = 1; i<=num; i++) {
_unique=false;
while (!_unique) {
_new = Math.round((Math.random()*max)+min);
for (j = 1; j<=i; j++) {
@koenpunt
koenpunt / chosen-bootstrap.css
Last active March 11, 2023 01:01
Bootstrap 3.0 theme for Chosen
select.form-control + .chosen-container.chosen-container-single .chosen-single {
display: block;
width: 100%;
height: 34px;
padding: 6px 12px;
font-size: 14px;
line-height: 1.428571429;
color: #555;
vertical-align: middle;
background-color: #fff;
@AviDuda
AviDuda / README.md
Last active April 23, 2024 10:32
Unmuting Twitch VODs
@cryptix
cryptix / vineScrape.go
Created August 27, 2014 12:31
extract a javascript object value from a html page using goquery and otto
package main
import (
"errors"
"log"
"os"
"github.com/PuerkitoBio/goquery"
"github.com/robertkrimen/otto"
)