This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
RED='\033[0;31m' | |
YELLOW='\033[1;33m' | |
NC='\033[0m' | |
CONTINUE_PROCESSING=true | |
while $CONTINUE_PROCESSING; do | |
# Read the next line to process |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require Logger | |
defmodule MinerJobWoker do | |
def start_link(worker_count, subscribe_options) do | |
# Start the producer | |
{:ok, producer_pid} = GenStage.start_link(__MODULE__.JobProducer, :ok) | |
# Override consumer subscribe options |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Subject to SQL injection | |
Student.query( | |
"SELECT * FROM student INNER JOIN course ON course.studentId=student.id WHERE student.id=" + req.param('student_id'), | |
function(err, students) { | |
} | |
) | |
// uses prepared statements to protect against sql injection | |
// https://github.com/brianc/node-postgres/wiki/Prepared-Statements#parameterized-queries |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ItemsController | |
def initialize | |
@items = [] | |
1.upto(10) do |i| | |
@items << { id: i, name: "Item #{i}" } | |
end | |
# => GET /items | |
def index |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Database | |
attr_accessor :contacts | |
def initialize | |
@contacts = [] | |
end | |
end | |
class Contact | |
attr_accessor :name, :age, :height, :weight |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
output: | |
initialize, <object> | |
initialize, undefined | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
class Device | |
attr_accessor :name | |
attr_reader :calculations | |
def initialize | |
@calculations = [] | |
end | |
def build_calculation(name) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'bcrypt' | |
Kernel.silence_warnings { | |
BCrypt::Engine::DEFAULT_COST = 1 | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Node < ActiveRecord::Base | |
belongs_to :parent_node, class: "Node" | |
has_many :children_nodes, class: "Node" | |
def find_all_children | |
all_children = [] | |
for cn in children_nodes | |
all_children << cn.find_all_children |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
getPlayers: (callback) -> | |
d3.json "/visualizer/players.json", (data) -> | |
for player in data.players | |
if (player.conqueror_id) | |
schemavere.players[player.conqueror_id] = player | |
if typeof callback is 'function' | |
callback() |
NewerOlder