Skip to content

Instantly share code, notes, and snippets.

View SergXIIIth's full-sized avatar

Sergey Makridenkov SergXIIIth

View GitHub Profile
@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]' [email protected]
# a.btn href='#' data-val='flat' Flat
# a.btn href='#' data-val='house' House
#
# Usage
@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 / 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 / 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 / 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 / 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 / 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}'
class Object
def blank?
self.nil?
end
def present?
!blank?
end
end
@SergXIIIth
SergXIIIth / task_1.cc
Last active August 29, 2015 13:57
Lab_1
#include <iostream>
#include <conio.h> // В этой библиотеке "живет" - getch();
/*
Исходные данные
---------------
Сумма вклада
Срок вклада, в месяцах
*/
@SergXIIIth
SergXIIIth / task_1.cc
Last active August 29, 2015 13:57
Lab_2
#include <iostream>
#include <conio.h>
using namespace std;
int main()
{
int period, interest;
float interest_in_period, amount, income;