Skip to content

Instantly share code, notes, and snippets.

@pk
pk / privnote.rb
Created May 27, 2014 14:34
Privnote naive implementation
require 'rubygems'
require 'bundler/setup'
require 'sinatra'
require 'securerandom'
NOTES = {}
get '/' do
response = '<html><body>'
response << %Q{<h1>Create secret note</h1>}
@pk
pk / gist:ed17387907c12cdfece3
Created November 28, 2014 13:26
Angular AuthSession model
/**
* Authentication session handling token and user id
*/
angular.module('fn.services.authentication', [])
.service('srvAuthenticationSession', ['$window', function ($window) {
this.save = function() {
var data = {'userId':this.userId, 'token':this.token};
$window.localStorage['com.fansnation.authorisationSession'] = JSON.stringify(data);
}
@pk
pk / gist:5552d00f36e624075302
Last active August 29, 2015 14:15
core/analytics.service.ts
angular
.module("core.analytics", [])
.service("Analytics", function($rootScope, $state){
this.handle = null;
this.setup = function(handle, trackerID){
if (!handle) {
console.log("Analytics: Unable to initialize plugin!");
return false;
@pk
pk / document.html
Created April 2, 2015 13:55
Practique printout
<!doctype html>
<html lang="en_GB">
<head>
<meta charset="utf-8">
<title>Content</title>
<script type="text/javascript" src="./print.js"></script>
<style>
/* Page layout, header, footer */
body {
" We're running Vim, not Vi!
set nocompatible
" Enable syntax highlighting
syntax on
" Faster response
set ttyfast
" No bell sound
set visualbell
" Line numbering
set number
#!/usr/bin/env ruby -w
owner = 'pavel.kunc@gmail.com'
gems = %w{
merb
merb-action-args
merb-assets
merb-auth-core
merb-auth-more
merb-auth-slice-password
@pk
pk / config.ru
Created February 16, 2010 12:25
Merb config.ru for Unicorn, Passenger and others
begin
require ::File.expand_path('.bundle/environment', __FILE__)
rescue LoadError
require 'rubygems'
require 'bundler'
Bundler.setup
end
require 'merb-core'
Merb::Config.setup(:merb_root => ::File.expand_path(::File.dirname(__FILE__)),
@pk
pk / split_repo.bash
Created March 18, 2010 15:38
Extract directory from the GIT repo to the standalone GIT repo.
#!/bin/bash
FROM=$1
TO=$2
echo "Spliting '$TO' from '$FROM'"
git clone --no-hardlinks $FROM $TO
cd $TO
git filter-branch --subdirectory-filter $TO HEAD -- --all
git reset --hard
git gc --aggressive
git prune
# vim:set filetype=ruby:
begin
require ::File.expand_path('.bundle/environment', __FILE__)
rescue LoadError
require 'rubygems'
require 'bundler'
Bundler.setup
end
require 'merb-core'
#!/bin/bash
CURRENT_DIR=`pwd`
for dir in $(find $1 -type d -depth 1 -not -name "\.*");
do
cd $dir
if [ -f *.gem ]; then
rm -rv *.gem
fi