Skip to content

Instantly share code, notes, and snippets.

View onsails's full-sized avatar
You only truly know it when you truly feel it

Andrey Kuznetsov onsails

You only truly know it when you truly feel it
View GitHub Profile
package com.onsails.pixel.spark
import java.text.SimpleDateFormat
import java.util.Date
import org.apache.hadoop.conf.Configuration
import org.apache.hadoop.io.Writable
import org.apache.hadoop.mapreduce._
import org.kiji.mapreduce.framework.KijiTableInputFormat
import spark.{Dependency, RDD, SerializableWritable, SparkContext, Split, TaskContext}
import org.kiji.schema.{KijiRowData, EntityId}
@onsails
onsails / puppet-install.sh
Last active December 11, 2015 18:48
Puppet installation script
#!/usr/bin/env bash
set -e
set -u
EXPECTED_ARGS=2
E_BADARGS=65
if [ $# -ne $EXPECTED_ARGS ]
then
echo "Usage: $0 master_hostname node_hostname"
@onsails
onsails / gist:2935299
Created June 15, 2012 08:00
Play20 IsAuthenticated helper
def IsAuthenticated(
f: => AuthenticatedRequest => Result,
x: => RequestHeader => Result = onUnauthorized) = {
Security.Authenticated(sessionUserId, x) { id =>
User.findById(id.toLong).map { user =>
Action(request => f(AuthenticatedRequest(user, request)))
}.getOrElse(
Action(request => onUnauthorized(request).withSession(Session())))
}
}
@onsails
onsails / .screenrc
Created October 31, 2011 16:59
My .screenrc
# GNU Screen configuration file
#
# Balaji S. Srinivasan <balajis_at_stanford_dot_edu>
# This file can be found at http://jinome.stanford.edu/stat366/unix/.screenrc
# Modified to play well with emacs, by moving Ctrl-A to Ctrl-T
# Modification of original files by Sven Guckes, Sarunas Vancevicius, and Mike Perry
# Sarunas Vancevicius original: http://www.redbrick.dcu.ie/~svan/configs/screenrc
# Mike Perry original: http://fscked.org/writings/225notes/unix/.screenrc
#!/usr/bin/env php
<?php
class ActiveResource {
/**
* The REST site address, e.g., http://user:pass@domain:port/
*/
var $site = false;
require 'couchrest_extended_document'
require 'couchsphinx'
require 'lib/sdb'
class Content < CouchRest::ExtendedDocument
use_database SERVER.default_database
property :content
property :title
property :url
# :%s/%appname%/_appname_/g
# :%s/%appname%/_username_/g
# :%s/%domain%/_domain_/g
set :application, "%appname%"
set :repository, "git@github.com:smix/%appname%.git"
set :deploy_to, "/var/rails/%appname%"
set :deploy_via, :remote_cache
set :branch, 'master'
set :scm, :git
<?php
echo <<<EOS
<?xml version="1.0" encoding="UTF-8" ?>
<Module>
<ModulePrefs title="My sponsors" />
<Content type="html">
<![CDATA[
<div style="background-color: #710;">
EOS;
if (!defined('_SAPE_USER')){
File.open("/etc/passwd").each_line do |line|
arr = line.split(":")
puts "#{arr.first} - #{arr.last}"
end
File.open("/etc/passwd") do |io|
io.each_line do |line|
arr = line.split(":")
puts "#{arr.first} - #{arr.last}"
end