Skip to content

Instantly share code, notes, and snippets.

View andreiglingeanu's full-sized avatar

Andrei Glingeanu andreiglingeanu

View GitHub Profile
@andreiglingeanu
andreiglingeanu / animate.js
Created February 25, 2013 16:17
javascript animate utility
/**
Docs: http://learn.javascript.ru/tutorial/lib
*/
/**
* Анимация. Параметры:
* opts.delta(time) -- временная функция, time=0..1. По умолчанию linear.
* opts.step(progress) -- функция рисования, progress=0..1.
* opts.complete -- функция, которая выполнится по окончании анимации
* opts.delay -- задержка между кадрами, по умолчанию 13
/**
* For modern browsers
* 1. The space content is one way to avoid an Opera bug when the
* contenteditable attribute is included anywhere else in the document.
* Otherwise it causes space to appear at the top and bottom of elements
* that are clearfixed.
* 2. The use of `table` rather than `block` is only necessary if using
* `:before` to contain the top-margins of child elements.
*/
.cf:before,
@andreiglingeanu
andreiglingeanu / inheritance.js
Created March 31, 2013 13:07
Function.prototype.method Function.prototype.inherits Function.prototype.swiss
Function.prototype.method = function ( name, func ) {
this.prototype[name] = func;
return this;
};
Function.method('inherits', function ( parent ) {
var depth = 0;
var proto = this.prototype = new parent();
inoremap <silent> <Bar> <Bar><Esc>:call <SID>align()<CR>a
function! s:align()
let p = '^\s*|\s.*\s|\s*$'
if exists(':Tabularize') && getline('.') =~# '^\s*|' && (getline(line('.')-1) =~# p || getline(line('.')+1) =~# p)
let column = strlen(substitute(getline('.')[0:col('.')],'[^|]','','g'))
let position = strlen(matchstr(getline('.')[0:col('.')],'.*|\s*\zs.*'))
Tabularize/|/l1
normal! 0
call search(repeat('[^|]*|',column).'\s\{-\}'.repeat('.',position),'ce',line('.'))
@andreiglingeanu
andreiglingeanu / rack_exercice.rb
Last active December 21, 2015 11:08
A Simple Rack Exercise
arg = ARGV[0]
raise "Argument is not passed." unless arg
app = lambda do |env|
[200, {"Content-Type" => "text/plain"}, ["Command line argument you typed was: #{arg}"]]
end
puts app.call({})
require "rack"
arg = ARGV[0]
raise "Argument is not passed." unless arg
app = lambda do |env|
[200, {"Content-Type" => "text/plain"}, ["Command line argument you typed was: #{arg}"]]
end
app = proc do |env|
res = Rack::Response.new
req = Rack::Request.new(env)
str = req.params['str']
res.finish do |res|
res['Content-Type'] = 'text/plain'
res.status = 200
res.write "Your string reversed is: #{str.reverse}"
end
@andreiglingeanu
andreiglingeanu / crack.c
Last active December 27, 2015 00:49 — forked from anonymous/crack.c
#define _XOPEN_SOURCE
#include <ctype.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
int yell_args(int argc, char** argv);
short is_password(const char* plain, const char* salt, const char* cipher);
short dict_attack(const char* salt, const char* cipher);
All of these resources were extremely valuable as I researched regex, finite state machines, and regex in Ruby. Check them out, they're full of fantastic information!
Articles
"Exploring Ruby's Regular Expression Algorithm" by Pat Shaughnessy
http://patshaughnessy.net/2012/4/3/exploring-rubys-regular-expression-algorithm
"Finite State Machines and Regular Expressions" by Eli Bendersky
http://www.gamedev.net/page/resources/_/technical/general-programming/finite-state-machines-and-regular-expressions-r3176
"Regular Expression Matching Can Be Simple and Fast" by Russ Cox
/*##########################################################################################
Prepend <span> in Flickr Widget
##########################################################################################*/
jQuery(document).ready(function($){
$('.ewd-banner-fixed').closest('.widget.widget_text').addClass('affix-banner');
var addFixed = false;
$(window).scroll(function (e) {