Skip to content

Instantly share code, notes, and snippets.

View noxious's full-sized avatar

Povilas Developer noxious

View GitHub Profile
@noxious
noxious / _tree
Created October 6, 2020 19:55 — forked from alexedwards/_tree
.
├── books
│   ├── handlers.go
│   └── models.go
├── config
│   └── db.go
└── main.go
@noxious
noxious / springboot.py
Created March 3, 2017 12:07 — forked from jonmcewen/springboot.py
nagios plugin for spring-boot app status
#!/usr/bin/env python
import requests, sys, getopt
try:
opts, args = getopt.getopt(sys.argv[1:], "p:", ["port="])
except getopt.GetoptError:
print('springboot.py -p <port>')
sys.exit(2)
@noxious
noxious / singleton.swift
Created July 24, 2015 05:46
singleton in swift
class TheOneAndOnlyKraken {
static let sharedInstance = TheOneAndOnlyKraken()
private init() {} //This prevents others from using the default '()' initializer for this class.
}
@noxious
noxious / gist:4041667
Created November 8, 2012 21:17 — forked from dhh/gist:893027
rspec vs Test::Unit
describe "GET current" do
before do
@request.cookies['hidden_notices'] = "1,#{notices(:permanent).id}"
get :current, :format => 'js'
end
it { should respond_with(:success) }
it { should set_cookie(:hidden_notices).to("#{notices(:permanent).id}") }
it { should render_template('notices/current') }
end
@noxious
noxious / latency.markdown
Created June 9, 2012 09:11 — forked from hellerbarde/latency.markdown
Latency numbers every programmer should know

Latency numbers every programmer should know

L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns
L2 cache reference ........................... 7 ns
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns             
Compress 1K bytes with Zippy ............. 3,000 ns  =   3 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns  =  20 µs
SSD random read ........................ 150,000 ns  = 150 µs

Read 1 MB sequentially from memory ..... 250,000 ns = 250 µs

@noxious
noxious / gist:1267135
Created October 6, 2011 11:00 — forked from alexisbernard/gist:270744
Fluent factory
# Fluent Factory overrides the new class method to provide an intuitive factory.
# Instead of using
# MyFactory.new_instance(args)
# Which may return an instance of MyClass, you now use
# MyClass.new(args)
# The second way is more intuitive and the big advantage is to use it rails and
# inheritance.
#
# Read the full example below to understand how to use it.
# class Animal
@noxious
noxious / spree_how_to.md
Created June 6, 2011 19:48 — forked from citrus/spree_how_to.md
Creating a Spree Site...

Creating a Spree Site

Here's how to get up and running on Spree Commerce...

We'll be using Rails3 and the Bundler gem. So make sure you've got those installed before moving on....

First create a new rails project:

rails new my_spree_site

@noxious
noxious / pulp_rate.rb
Created April 28, 2011 04:26 — forked from tomash/pulp_rate.rb
Spree shipping cost calculator
class Calculator::PulpRate < Calculator
preference :category1_rate, :decimal, :default => 0
preference :category2_rate, :decimal, :default => 0
preference :category3_rate, :decimal, :default => 0
preference :category4_rate, :decimal, :default => 0
preference :category5_rate, :decimal, :default => 0
WEIGHT_RANGES = {
0..350 => :preferred_category1_rate,
351..500 => :preferred_category2_rate,