Skip to content

Instantly share code, notes, and snippets.

View sudodoki's full-sized avatar

Джон, просто Джон sudodoki

View GitHub Profile
@sudodoki
sudodoki / Describe
Last active December 21, 2015 01:38
Sublime Text 2 Snippets
<snippet>
<content><![CDATA[
describe("${1:Subject}", function(){
${2:// Your code goes here.}
});
]]></content>
<tabTrigger>describe</tabTrigger>
</snippet>
// Get the model's index by id or fall back to underscore's method
indexOf: function(sought) {
if (typeof sought === "string") {
if (!this._byId[sought]) {
return -1;
};
if (_.indexOf.call(_, this.pluck('id'), sought) !== -1) {
return _.indexOf.call(_, this.pluck('id'), sought)
}
return _.pluck(this.models, 'cid').indexOf(sought)
@sudodoki
sudodoki / gist:6630060
Created September 19, 2013 21:25
Angular Interceptors
// Set up ajax Interceptors
app.factory('myHttpInterceptor', ["$q", "$rootScope",function ($q, $rootScope) {
return {
'request': function(config) {
// do something on success
$rootScope.$broadcast('request')
console.log(config)
return config
},
@sudodoki
sudodoki / hsl2rgb.js
Created September 21, 2013 14:33
function to convert hsl values into rgb
/**
* function to convert hue, saturation, lightness in browser
* @param {integer} h in range of 0..360
* @param {saturation} s in range of 0..100 (percents)
* @param {lightness} l in range of 0..100 (percents)
* @return {array} array [r, g, b] of integers (0..255) representing each part
*/
hsl2rgb = function (h, s, l) {
var transmitter = document.createElement("div");
hsl2rgb = function () {
// from http://vvsite.com.ua/?attachment_id=783
//<!--
var cifir_ru= new Array("од","дв","три","четыр","пят","шест","сем","восем","девят");
var sotN_ru=new Array("сто","двести","триста","четыреста","пятьсот","шестьсот","семьмот","восемьсот","девятьсот");
var milion_ru=new Array("триллион","миллиард","миллион","тысяч");
var anDan_ru =new Array("","","","сорок","","","","","девяносто");
function SPRU(XS){
(XS>0? this.XS=sumPROPRU(Math.floor(XS),Math.round((XS-Math.floor(XS))*100)) : this.XS="Пусто!" );
return this;
require './calculator_class'
puts "Enter numbers divided by spaces"
begin
# chop is used to get rid of '\n' new char line that's the last one in gets when finishing line input
numbers = gets.chop.split.grep(/-?\d+/) do |possible_num|
begin
# unlike to_i, Integer throws exception if input is somehow invalid (letters, etc)
Integer(possible_num)
@sudodoki
sudodoki / gist:6851369
Created October 6, 2013 08:51
escaping .^$*+?()[{\| using regexp in javascript
// escaping .^$*+?()[{\|
separator = separator.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
@font-face {
font-family: 'Lobster';
font-style: normal;
font-weight: 400;
src: local('Lobster'), url(http://themes.googleusercontent.com/static/fonts/lobster/v5/vAXzwlQm5f2XqUwV0l0P2w.woff) format('woff');
}
@font-face {
font-family: 'Goudy Bookletter 1911';
font-style: normal;
@sudodoki
sudodoki / gist:7045452
Created October 18, 2013 17:57
E2E test fail
describe("E2E: Testing Routes", function() {
console.log('this e2e ran')
beforeEach(function() {
browser().navigateTo('/');
});
it('should jump to the /videos path when / is accessed', function() {
browser().navigateTo('/#/');
expect(browser().location().hash()).toBe("#/chart/demographics");
});
@sudodoki
sudodoki / gist:7308154
Created November 4, 2013 19:45
Home Work for HTML.
Write (pure) HTML code for home page for some abstract project.
It should have:
1. navigation menu that has several anchored links that are pointing to different sections on page ('#about, '#faq', '#contacts', '#register')
2. several sections:
a) about: section that has a large copy of text , several paragraphs with description of product, possibly, a large image to capture attention
b) faq: list of frequently asked questions
b) contacts: some addresses (email-phones), blogs-twitter, etc.
c) register: form that captures email/password/password confirmation
d) feedback form?