Skip to content

Instantly share code, notes, and snippets.

describe 'sponsored pushes' do
@league = create(:soccer_league) # <- .create() not in context outside of let/before blocks
@job_data = { # <- can't be defined inside let block if used in before(:context)
tube: @tube_name,
message: @message,
article_uri: @article_uri,
category: @category,
league: @league
primary_tag_uris: @primary_tag_uris,
resource_uris: @resource_uris
class ScoreChangeEvents
class << self
def all
{ football: football, soccer: soccer, baseball: baseball }
end
def save(foo = all)
File.write(
'foo',
"Occurrance Rate:\n\nFootball: #{foo[:football].count} / #{Football::Event.count}\n\nSoccer: #{foo[:soccer].count} / #{Soccer::Event.count}\n\nBaseball: #{foo[:baseball].count} / #{Baseball::Event.count}\n\n```js\n#{JSON.pretty_generate foo}\n```")
obj = {}
Football::Event.all.each { |e|
obj[e.id] = { summaries: e.box_score.score_summaries.map { |s|
{ home: s.home_score, away: s.away_score } unless s.home_score == 0 and s.away_score == 0 }
} if e.box_score
}
obj.delete_if { |k,v| v[:summaries].compact.empty? == true }
obj.delete_if { |k,v|
# WARNING:
# Horrible things happening here for development reasons.
# Do not leave this in.
require 'colorize'
module Zing
module PlayerRecommender
class Todo
def self.warn
str ||= ''
@noam87
noam87 / gist:c5e2ab8dc48498a9fa91
Created August 19, 2014 04:41
shitty neural network example
/**
* Trainins input vectors.
*
* Input used to train neural network.
*/
// Square
var s_1 = [
-1, -1, -1, -1, -1,
-1, 1, 1, 1, -1,
var sample = [
[0,1],
[0,2],
[0,3],
[3,8],
[3,9],
[4,8],
[4,10],
[3,1],
use std::str::from_utf8;
use std::io::{TcpListener, TcpStream};
use std::io::{Acceptor, Listener};
fn main() {
let listener = TcpListener::bind("0.0.0.0", 8000);
let mut acceptor = listener.listen();
fn handle_client(mut stream: TcpStream) {
@noam87
noam87 / gist:c3a8e789eb6876011c70
Created June 8, 2014 00:54
ubuntu virtualbox vm

eth0 : bridged

eth1 : host only

configure /etc/network/interfaces like so:

auto lo
iface lo inet loopback
@noam87
noam87 / gist:6258984
Last active December 21, 2015 05:39
Strange gsub bug

Problem solved by geniuses on IRC: check final comment for complete log. The cause of this bug is unexpected to say the least!


This is the code that isn't working:

Assume the input is "Hello world @123"

def memo_content(input, remote: false)

content = sanitize input

@noam87
noam87 / gist:4957762
Last active December 13, 2015 18:48
Notes on screencasting in Linux. Video tutorial here: http://youtu.be/c3EFVviXS40

Screencasting in Linux

These are my notes for my guide on screencasting in Linux. The instructional screencast can be found here link.

Tools used

  • arandr (easily manage your screens and their resolution)

  • recordmydesktop (record your desktop activity)