Skip to content

Instantly share code, notes, and snippets.

View denysxftr's full-sized avatar

Denys Serhiienko denysxftr

View GitHub Profile
@denysxftr
denysxftr / Gruntfile.js
Created August 4, 2014 21:08
build assets
module.exports = function(grunt) {
grunt.initConfig({
pkg: '<json:package.json>',
concat: {
js: {
src: 'app/public/js/src/*.js',
dest: 'app/public/js/app.js'
},
css: {
#!/usr/bin/env zsh
#local return_code="%(?..%{$fg[red]%}%? ↵%{$reset_color%})"
setopt promptsubst
autoload -U add-zsh-hook
PROMPT_SUCCESS_COLOR=$FG[117]
PROMPT_FAILURE_COLOR=$FG[124]
PROMPT_VCS_INFO_COLOR=$FG[242]
@denysxftr
denysxftr / gulpfile.js
Created January 9, 2015 16:04
gulp + browserify + uglify + watch
var gulp = require('gulp');
var uglify = require('gulp-uglify');
var streamify = require('gulp-streamify');
var browserify = require('browserify');
var source = require('vinyl-source-stream');
var del = require('del');
var paths = {
js: './app/assets/js/app.js',
watch_js: ['app/assets/js/**/*.js', 'app/assets/js/*.js']
markup = Hbuilder::Builder.html do
div class: 'main' do
h1 body: 'hello world'
p body: 'some text lalalalal'
img alt: 'lalalal', src: 'http://placekitten.com/200/300'
end
end
markup # =>
@denysxftr
denysxftr / app.rb
Last active August 29, 2015 14:17
arheom lab1
TIMES = ENV["TIMES"] ? ENV["TIMES"].to_i : 10000000
WIDTH = `tput cols`.to_i - 23
def timer
t1 = Time.now
yield
Time.now - t1
end
TIMES_TIME = timer { TIMES.times {} }
@denysxftr
denysxftr / computed.rb
Created April 3, 2015 22:59
computed ruby functions test
class RApp
def initialize(app)
@_computed_methods = app[:computed]
set_bindings(app[:vars])
end
private
def set_bindings(vars)
vars.each do |k,v|
@denysxftr
denysxftr / lab3.pl
Created April 5, 2015 15:08
List of N max elements from list
min(X, Y, X) :- X < Y.
min(X, Y, Y) :- X >= Y.
max(X, Y, X) :- X >= Y.
max(X, Y, Y) :- X < Y.
min_member([X], X).
min_member([H | T], X) :- min_member(T, I), min(H, I, X).
remove(_, [], []).
@denysxftr
denysxftr / lab15.pl
Created April 5, 2015 15:09
Find the most frequent element from list.
%% PACK SECTION
pack([X|Unpacked], Packed) :- pack(Unpacked, [[X]], Packed).
pack([H|T], [[H|Acc]|Rest], Packed) :- pack(T, [[H,H|Acc]|Rest], Packed).
pack([X|T], [[Y|Acc]|Rest], Packed) :-
X \= Y,
pack(T, [[X],[Y|Acc]|Rest], Packed).
pack([], RPacked, Packed) :- reverse(RPacked, Packed).
% UTILS SECTION
@denysxftr
denysxftr / v-jquery-change.js
Created May 12, 2015 13:44
custom vue js directive for jquery events
Vue.directive('jquery-change', {
twoWay: true,
bind: function() {
var self = this;
$(self.el).on('change', function() {
self.set(this.value);
});
},
update: function(data) {
if(data) {
folder_path = ENV['FOLDER']
from = Regexp.new(ENV['FROM'])
to = ENV['TO']
Dir.glob(folder_path + "*").sort.each do |f|
filename = File.basename(f, File.extname(f))
new_filename = filename.gsub(from, to)
File.rename(f, folder_path + new_filename + File.extname(f))
end