Skip to content

Instantly share code, notes, and snippets.

@AlexVKO
AlexVKO / Default (OSX).sublime-keymap
Last active August 29, 2015 14:24
My sublime settings
[
{"keys": ["alt+up"], "command": "move", "args": {"by": "stops", "empty_line": true, "forward": false}},
{"keys": ["alt+down"], "command": "move", "args": {"by": "stops", "empty_line": true, "forward": true}},
{"keys": ["shift+alt+up"], "command": "move", "args": {"by": "stops", "empty_line": true, "forward": false, "extend": true}},
{"keys": ["shift+alt+down"], "command": "move", "args": {"by": "stops", "empty_line": true, "forward": true, "extend": true}},
{"keys": ["shift+ctrl+["], "command": "focus_group", "args": { "group": 0 } },
{"keys": ["shift+ctrl+]"], "command": "focus_group", "args": { "group": 1 } },
{"keys": ["ctrl+super+shift+["], "command": "move_to_group", "args": { "group": 0 } },
{"keys": ["ctrl+super+shift+]"], "command": "move_to_group", "args": { "group": 1 } },
]
@AlexVKO
AlexVKO / Resource.service.js
Created July 13, 2015 05:16
Make $resource respond to PUT or POST with $save
module.factory( 'Resource', [ '$resource', function( $resource ) {
return function( url, params, methods ) {
var defaults = {
update: { method: 'put', isArray: false },
create: { method: 'post' }
};
methods = angular.extend( defaults, methods );
var resource = $resource( url, params, methods );
@AlexVKO
AlexVKO / base16-eighties.dark.tmTheme
Last active August 29, 2015 14:24
base16-eighties modified
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>author</key>
<string>Chris Kempson (http://chriskempson.com)</string>
<key>name</key>
<string>Base16 Eighties Dark</string>
<key>semanticClass</key>
<string>base16.eighties.dark</string>
@AlexVKO
AlexVKO / gist:f25175b9b6255d692702
Created July 15, 2015 00:11
Tip To highlight angular ng-* attributes in html
Open your theme file located at Packages/Color Scheme - Default/*.tmTheme
find <dict> tag containing <string>Tag attribute</string> and add section after
<dict>
<key>name</key>
<string>Tag ng attribute</string>
<key>scope</key>
<string>entity.other.attribute-name.ng</string>
<key>settings</key>
<dict>
<key>fontStyle</key>
@AlexVKO
AlexVKO / Thema Dark
Last active September 9, 2015 08:29
Another custom theme, focused on readability
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>author</key>
<string>Chris Kempson (http://chriskempson.com)</string>
<key>name</key>
<string>Base16 Eighties Dark</string>
<key>semanticClass</key>
<string>base16.eighties.dark</string>
@AlexVKO
AlexVKO / HTML.tmLanguage
Last active August 29, 2015 14:24
Language HTML improved for angularjs 1.x
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>fileTypes</key>
<array>
<string>html</string>
<string>htm</string>
<string>shtml</string>
<string>xhtml</string>
@AlexVKO
AlexVKO / job.rb
Last active November 10, 2015 03:23
Code for matching between Trainees And Jobs
module Matching
extend ActiveSupport::Concern
def run_matching trainee
self.trainee = trainee
self.matching = {rate: 0}
self.weight_of_exact = { city: 19.3, course: 13.9, semester: 19.3, languages: 17.4, other_courses: 21.3 }
self.run
end
@AlexVKO
AlexVKO / filters.css
Created July 19, 2015 11:45
Example of CSS webkit filters
/*Filter styles*/
.saturate {-webkit-filter: saturate(3);}
.grayscale {-webkit-filter: grayscale(100%);}
.contrast {-webkit-filter: contrast(160%);}
.brightness {-webkit-filter: brightness(0.25);}
.blur {-webkit-filter: blur(3px);}
.invert {-webkit-filter: invert(100%);}
.sepia {-webkit-filter: sepia(100%);}
.huerotate {-webkit-filter: hue-rotate(180deg);}
.rss.opacity {-webkit-filter: opacity(50%);}
@AlexVKO
AlexVKO / gemfile.rb
Last active October 1, 2015 21:36
my most used Gems for Rails API
source 'https://rubygems.org'
gem 'rails', '4.2.3'
gem 'active_model_serializers' # Serialize json response
gem 'delayed_job_active_record' # Asynchronous priority queue system
gem 'figaro' # For setting environment variables
gem 'kaminari' # for pagination
gem 'newrelic_rpm' # Monitor
gem 'pg' # Posgrees Database
@AlexVKO
AlexVKO / add_unaccent_to_postgres
Created September 19, 2015 19:48
Adding extensions to Postgresql database with Rails
The default Postgresql installation on Mac OS X using homebrew includes a single extension - plpgsql (PL/pgSQL procedural language) but there are a number of them available in the lib directory (/usr/local/Cellar/postgresql/9.2.1/lib on my machine)
To install an extension into the database, the easiest way I found was to open a database console using the 'rails db' command and then create it directly. I have seen mention of doing this in a Rails migration but this did not work for me.
Note that an extension is installed in a specific database, rather than being added to all databases.
The command to list the installed extensions is '\dx'
$ rails db
psql (9.2.1)