Skip to content

Instantly share code, notes, and snippets.

View SergXIIIth's full-sized avatar

Sergey Makridenkov SergXIIIth

View GitHub Profile
/**
* jQuery.fn.sortElements
* --------------
* @author James Padolsey (http://james.padolsey.com)
* @version 0.11
* @updated 18-MAR-2010
* --------------
* @param Function comparator:
* Exactly the same behaviour as [1,2,3].sort(comparator)
*
@SergXIIIth
SergXIIIth / gist:1628715
Created January 17, 2012 20:31
The first Arduino HTTP request
#include <SPI.h>
#include <Ethernet.h>
byte mac[] = { 0x00, 0xAB, 0xCB, 0xCD, 0xDE, 0x02 };
IPAddress ip(192,168,0,140);
IPAddress server(173,194,70,103);
EthernetClient client;
@SergXIIIth
SergXIIIth / compile_asserts.rb
Last active December 24, 2015 17:39
Compile assets (Coffee, Sass, Serenadejs) in pure Ruby
require 'rubygems'
require 'bundler/setup'
require 'coffee-script'
require 'sass'
require 'fileutils'
require 'execjs'
require 'multi_json'
support_pattern = '{**/*.serenade,**/*.coffee,**/*.sass}'
@SergXIIIth
SergXIIIth / gist:6426527
Last active December 22, 2015 05:49
Jasmine sleep function. Helpful to wait until DOM events handled.
window.sleep = (ms, and_runs) ->
flag = false
runs ->
setTimeout ->
flag = true
, ms
waitsFor ->
flag
@SergXIIIth
SergXIIIth / Rakefile
Last active December 20, 2015 22:59
Simple solution, a rake task for use CoffeeScript in Jasmine. Supported: 1. write code in CoffeeScript 2. write spec in CoffeeScript. Could be used in any Ruby application (Sinatra, Rails ...)
require 'bundler/gem_tasks'
require 'jasmine'
require 'coffee-script'
require 'fileutils'
load 'jasmine/tasks/jasmine.rake'
task 'test' do
pattern = '{**/*.rb,**/*.slim,**/*.coffee}'
@SergXIIIth
SergXIIIth / vk_download.js
Created May 13, 2013 15:13
Download music from vk.com. 1. Run vk_download.js inside your music 2. Save result json to file "tracks.json" 3. Run "ruby vk_download.rb" Music we be in "./tracks"
function async_init() {
var element, type, src;
var parent = document.getElementsByTagName('body');
var cdn = new Array;
cdn[0] = '//ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js';
for (var i in cdn) {
element = document.createElement('script');
@SergXIIIth
SergXIIIth / vk_download.js
Created May 13, 2013 15:13
Download music from vk.com. 1. Run vk_download.js inside your music 2. Save result json to file "tracks.json" 3. Run "ruby vk_download.rb" Music will be in "./tracks"
function async_init() {
var element, type, src;
var parent = document.getElementsByTagName('body');
var cdn = new Array;
cdn[0] = '//ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js';
for (var i in cdn) {
element = document.createElement('script');
@SergXIIIth
SergXIIIth / gist:4977359
Created February 18, 2013 13:24
Encryption Ruby On Rails
secret = Digest::SHA1.hexdigest("yourpass")
a = ActiveSupport::MessageEncryptor.new(secret)
b = a.encrypt("eh")
c = ActiveSupport::MessageEncryptor.new(secret)
c.decrypt(b)
@SergXIIIth
SergXIIIth / buttons_radio.js.coffee
Created December 17, 2012 21:11
Automatic create and set html hidden field base on Bootstrap buttons radio values Javascript/Coffeescript plugin
# Automatic create and set html hidden field
# base on Bootstrap buttons radio values
# Javascript/Coffeescript plugin
#
# Html/Slim
# .btn-group data-toggle='buttons-radio' data-field='offer[type]' data-init-val=@offer.type
# a.btn href='#' data-val='flat' Flat
# a.btn href='#' data-val='house' House
#
# Usage
@SergXIIIth
SergXIIIth / probe.c
Created November 6, 2015 08:16
Take metadata from video
// gcc src/decoder.c -lavcodec -lavformat
#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>
int main(int argc, char *argv[]) {
char *filename = "/home/msa/Videos/Cowspiracy.2014.1080p-EGN.mkv";
av_register_all();