Skip to content

Instantly share code, notes, and snippets.

View brikis98's full-sized avatar

Yevgeniy Brikman brikis98

View GitHub Profile
@brikis98
brikis98 / Average page views by industry
Created November 2, 2011 03:57
Apache Pig Script Example
pv_by_industry = GROUP profile_view by viewee_industry_id
pv_avg_by_industry = FOREACH pv_by_industry
GENERATE group as viewee_industry_id, AVG(profie_view) AS average_pv;
@brikis98
brikis98 / BinaryModules.js
Created December 1, 2011 00:45
Node.js performance tips
// Use built in or binary modules
var crypto = require('crypto');
var hash = crypto.createHmac("sha1",key).update(signatureBase).digest("base64");
@brikis98
brikis98 / NameFormatter.java
Created December 7, 2011 03:57
Name Formatter
public interface NameFormatter
{
enum Style
{
FAMILIAR_NAME,
FULL_NAME,
LIST_NAME
};
public String format(String firstName, String lastName, String maidenName, Style style);
@brikis98
brikis98 / express.js
Created January 16, 2012 23:14
Sample code for developer happiness blog post
var app = express.createServer();
app.get('/', function(req, res){
res.send('Hello World');
});
app.listen(3000);
@brikis98
brikis98 / bql_example.sql
Created January 26, 2012 18:50
Sensei BQL example
SELECT _uid,_score,color
FROM members
WHERE color="red" AND
category IN ("van","exotic") AND
MATCH(contents)
AGAINST("cool leather seats")
GROUP BY color TOP 3
BROWSE BY color,category
ORDER BY RELEVANCE
LIMIT 0,10
@brikis98
brikis98 / GuessNumber.java
Created January 29, 2012 20:54
Seven Languages in Seven Weeks: Ruby, Day 1
import java.util.Random;
import java.util.Scanner;
public class GuessNumber {
public static void main(String[] args) {
Random generator = new Random();
int toGuess = generator.nextInt(10) + 1;
int guess;
Scanner scanner = new Scanner(System.in);
try {
@brikis98
brikis98 / Grep.java
Created January 29, 2012 22:11
Seven Languages in Seven Weeks: Ruby, Day 2
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.regex.Pattern;
import java.util.regex.Matcher;
/**
* Usage: java Grep <regular_expression> <file_name>
*/
@brikis98
brikis98 / LinkedInProfile.rb
Created February 1, 2012 05:17
Seven Languages in Seven Weeks: Ruby, Day 3
class LinkedInProfile
SIMPLE_PROFILE_FIELDS = %w[id summary headline honors interests specialties industry first_name last_name public_profile_url picture_url associations]
SIMPLE_PROFILE_FIELDS.each do |field|
define_method(field.to_sym) do
@json[field]
end
end
def initialize(json)
@brikis98
brikis98 / DynamicCodeSlot.io
Created February 3, 2012 08:50
Seven Languages in Seven Weeks: Io, Day 1
TestObject := Object clone do(
foo := method("you called foo" println)
bar := method("you called bar" println)
baz := method("you called baz" println)
)
TestObject getSlot(System args at(1)) call
/*
@brikis98
brikis98 / ComplexNumbers.io
Created February 4, 2012 09:15
Seven Languages in Seven Weeks: Io, Day 2
Complex := Object clone do (
setValues := method(real, imaginary,
self real := real;
self imaginary := imaginary;
self
)
+ := method(other,
result := Complex clone setValues(self real + other real, self imaginary + other imaginary)
)
)