Skip to content

Instantly share code, notes, and snippets.

View sergeylukin's full-sized avatar
🎯
Focusing

Sergey Lukin sergeylukin

🎯
Focusing
View GitHub Profile
@sergeylukin
sergeylukin / post-receive
Last active August 29, 2015 13:55
git hook that sets flags according to modified files
while read oldrev newrev refname
do
COMPILE_JAVASCRIPTS=0
COMPILE_IMAGES=0
COMPILE_STYLESHEETS=0
for file in `git diff $oldrev $newrev --name-only`; do
if [ `echo $file | cut -c 1-22` == "app/assets/javascripts" \
-o \
`echo $file | cut -c 1-25` == "shared/assets/javascripts" \
@sergeylukin
sergeylukin / readme.md
Last active August 29, 2015 14:07
Programs browser for DOS 6.22

Browser

browser.exe displays programs found in current directory's subdirectories in an easy to look through interface. Programs meta information (name, description, screenshots references) is stored in browser.yaml file found in programs' directory.

Here is UI prototype:

@sergeylukin
sergeylukin / monitoring.sh
Created March 7, 2012 12:47
Bash: launch monitoring terminals
#!/bin/bash
#
# Script Name: Launch terminals for monitoring
# Author: Sergey Lukin
#
#
# Wait for Network to be available.
while true
do
ping -c 1 10.0.0.248
@sergeylukin
sergeylukin / commit-msg
Last active October 7, 2015 13:58
Git hook: prefix BRANCH name in every COMMIT
#!/bin/sh
#
# Adds current branch name as a prefix for every Commit
#
# To enable this hook, rename this file to "commit-msg" and make sure it is executable
#
ticket=$(git symbolic-ref HEAD | awk -F'/' '{print $3}')
if [ -n "$ticket" ]; then
sed -i "1 s/^/$ticket: /" $1
@sergeylukin
sergeylukin / pre-receive
Last active October 7, 2015 13:58
Git hook (pre-receive): commit any local changes before PUSH accepted
#!/bin/sh
#
# This hooks is placed in a Bare repository
# It makes sure that working tree doesn't contain any local changes
# And if it contains - submits a commit and returns false
# So if false returned - client should PULL and then PUSH again
#
# Assuming following file structure:
# .
# |-- myproject
@sergeylukin
sergeylukin / newdraft
Created August 25, 2012 16:50
Ruby script for creating New Draft Post in Jekyll
#!/usr/bin/env ruby
unless ARGV[0]
puts 'Usage: newdraft "the draft title"'
exit(-1)
end
date_prefix = Time.now.strftime("%Y-%m-%d")
post_name = ARGV.join ' '
post_file_name = post_name.strip.downcase.gsub(/ /, '-')
@sergeylukin
sergeylukin / WORKSTATION
Created November 7, 2012 16:36
FreeBSD 9 KERNEL for ThinkPad T60
include GENERIC
# Exclude CPU types
nocpu I486_CPU
nocpu I586_CPU
ident WORKSTATION
# Disable mount partitions from UNIX server over TCP/IP
# Enable when needed
@sergeylukin
sergeylukin / xorg.conf
Created November 8, 2012 14:09
FreeBSD X11 configuration file for ThinkPad T60
Section "ServerLayout"
Identifier "X.org Configured"
Screen 0 "Screen0" 0 0
InputDevice "Mouse0" "CorePointer"
InputDevice "Keyboard0" "CoreKeyboard"
EndSection
Section "Files"
ModulePath "/usr/local/lib/xorg/modules"
FontPath "/usr/local/lib/X11/fonts/misc/"
class ServicesController < ApplicationController before_filter :authenticate_user!, :except => [:create] def index # get all authentication services assigned to the current user @services = current_user.services.all end def destroy # remove an authentication service linked to the current user @service = current_user.services.find(params[:id]) @service.destroy redirect_to services_path end def create # get the service parameter from the Rails router params[:service] ? service_route = params[:service] : service_route = 'no service (invalid callback)' # get the full hash from omniauth omniauth = request.env['omniauth.auth'] # continue only if hash and parameter exist if omniauth and params[:service] # map the returned hashes to our variables first - the hashes differ for every service if service_route == 'facebook' omniauth['extra']['user_hash']['email'] ? email = omniauth['extra']['user_hash']['email'] : email = '' omniauth['extra']['user_hash']['name'] ? name = omniaut
@sergeylukin
sergeylukin / awk_vs_grep.sh
Last active December 17, 2015 06:19
Profiling AWK vs GREP in sorting file contents in custom order (AWK is 2 times faster)
#! /usr/bin/env sh
###
### awk_vs_grep.sh - Profiles 2 methods used to sort file contents using custom pattern
### make sure to have file "awk_vs_grep.txt" with some content
### for more details refer to this Question: http://unix.stackexchange.com/questions/75498/sort-using-custom-pattern/
###
### Usage: `./awk_vs_grep.sh` - will execute commands 10 times and only print profile results
### Usage: `./awk_vs_grep.sh 1000` - will execute commands 1000 times and only print profile results
### Usage: `./awk_vs_grep.sh 1000 /dev/tty` - will execute commands 1000 times and print commands output + results