Skip to content

Instantly share code, notes, and snippets.

@ershad
ershad / nem
Created April 2, 2011 15:37
A very small python script to call emacs with "-nw" parameter so that it opens inside the terminal. Copy it to /bin/ dir to start using :)
#!/usr/bin/python
# Copyright 2011 Ershad K <ershad92@[nospam]gmail.com>
# Licensed under GPL Version 3
import sys
import os
arguments = ""
sys.argv.remove(sys.argv[0])
@ershad
ershad / stringPermutation.c
Created September 25, 2011 17:21
String permutation
#include <stdio.h>
#include <string.h>
#define MAX 50
void permutations(char *string, int k, int m);
void swap(char *x, char *y);
int main(int argc, char *argv[])
{
// char string[MAX];
@ershad
ershad / solve1-1.py
Created September 28, 2011 07:33
A script to solve a problem in algo textbook :D
# Python script to solve the problem 1-1 in 'Introduction to Algorithms - Cormen, Leiserson, Rivest, Stein (3rd edition)'
# Ershad K <ershad92@gmail.com>
# License: GPL Version 3
from math import *
import sys
def f_(n):
return n**3
# Define the desired f(n) here and return the value.
@ershad
ershad / gist:5432939
Created April 22, 2013 07:02
Junil's public key
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDgyWWO34d6yt5bEsQc549bGY5YKZv2lrsWaqF6iXo6WJBsWh1wAVdeQMYdv7ufc/hMJhF1QyrCynA1joV676o73fgTLQ6z4MxkTW5OMjO7gvjoNgX51BOKzch/tGTy0hUN4DcM4VJhz/CGXOUrhgCYRbfUDI8+QG5Xe37JVjEqADnDcGzDmXs/+m9iWTZ/J3/BB6TNz78LghtsqTiM2VC5eUz50wuW6LhY6HNrlbEsSMkJ5x1xTXrNqgSSvoW66rZbOGTGuNE1re8gM/KAsuUJz4idh2FtEe5YJnfUw6tvgp2bvV6412G1bgYSmCrmG+EzWOMyPT389r8oZVjHuXcJ junil@junil-Inspiron-N4050
no change in User#usertype
def present_user
user_signed_in? ? current_user : non_logged_in_user
end
def non_logged_in_user
unverified_user_undo? ? unverified_user : User.new
end
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')
ISBN
DDC
Publisher subject category
Original language if translation
Book No.1
Book No.2
Author 1, Personal, Main
Author 1, Personal, Main - Role
Author 1, Corporate, Main
Author 2, Personal, Added
# Usage:
# shell$ irb
# 1.9.3p194 :001 > require '~/Desktop/Po'
# 1.9.3p194 :002 > Po.new('~/code/translation/evolution-data-server.master.ml.po').split(3, 'evolution.po')
# Files named 1_evolution.po, 2_evolution.po, 3_evolution.po will be written to your current working directory.
class Po
attr_accessor :po_file_array
def initialize(file)
// Show GitHub organizations
// Example: "company1", "company2"
"include_orgs": [],
# encoding: utf-8
require 'xmlsimple'
require 'csv'
hash = XmlSimple.xml_in('m.xml')
start_date = DateTime.parse "2013-12-28"
end_data = Date.today