Skip to content

Instantly share code, notes, and snippets.

@osv
osv / gist:8d62e3ea5f0539c6f821
Created March 4, 2015 12:03
ua-ru translate js, translate miss ru keyboard
var transliterate = (
function() {
var
rus = "щ ш ч ц ю я ё ж ъ ы э а б в г д е з и й к л м н о п р с т у ф х ь і ї є ґ".split(/ +/g),
eng = "shh sh ch cz yu ya yo zh ' y e a b v g d e z i j k l m n o p r s t u f x ` i yi e g".split(/ +/g);
return function(text, engToRus) {
if (!text)
return "";
var x;
@osv
osv / gist:258948f7d59ef797fde7
Last active August 29, 2015 14:17
Convert mongo collection to jquery select2 data
/*
Convert mongo collection data to select2 data array that support children (nested)
I use it for convert Meteor collection to select2 data
Example:
data = [ {_id: 1, name: "foo1"},
{_id: 2, name: "child 1 of foo1", p: 1}
{_id: 3, name: "child 2 of foo1", p: 1}
@osv
osv / search.services.js
Last active September 18, 2015 13:19
angular pretty url like "/search/city=Dnipropetrovsk;gender=female;time=8:00..12:00"
'use strict';
angular.module('app')
/*
* Next service used to make more readable url
*
* Example:
*
* $stateProvider
* .state('searchfilter', {
* url: '/searchfilter{filter:string}', // not :any, but :string type
@osv
osv / .Xdefaults
Created October 31, 2015 14:32
.Xdefaults xterm + urxvt
! Add into you #include ".Xdefaults-pub"
urxvt.geometry: 120x45
! Bind C-0, C-+ and C-= to activate medium, big and small font size respectively.
urxvt.font: xft:DejaVu Sans Mono
urxvt.font1: xft:Kozuka Gothic Pr6N
urxvt.keysym.C-0: command:\033]710;xft:DejaVu Sans Mono\007
urxvt.keysym.C-minus: command:\033]710;xft:DejaVu Sans Mono-7\007
urxvt.keysym.C-equal: command:\033]710;xft:DejaVu Sans Mono-16\007
@osv
osv / terms.js
Created December 4, 2015 09:44
ng-translate terms and condiutnion. Right way
updateTC();
$scope.$watch('$translateLoadingEnd', defferedUpdateTC);
function updateTC(arg) {
$translate('frontend.links.terms_and_conditions').then(function(termsText) {
// state to terms
var href = $state.href('app.terms-and-conditions', {lang: $rootScope.currentLocale}),
urledTerms = '<a href="'+ href +'">' + termsText + '</a>';
@osv
osv / ev.coffee
Created December 26, 2015 09:46
Prevent default drop behavior (loading a file) outside of the drop zone
# Prevent default drop behavior (loading a file) outside of the drop zone
window.addEventListener 'dragover', ((e) -> e.preventDefault()), false
window.addEventListener 'drop', ((e) -> e.preventDefault()), false
@osv
osv / server-meteor-paypal.js
Created January 8, 2016 11:34
server side paypal class
var paypal = new PaypalSDK();
Meteor.startup(function ObservePaypalSettings() {
/*
var paypalSchema = new SimpleSchema({
enable: {
type: Boolean,
defaultValue: false,
},
isSandBox: {
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>XX:TITLE</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width,initial-scale=1" />
</head>
@osv
osv / gist:53eef63c59a3244a7e8f
Created February 21, 2015 21:01
Meteor drag drop upload
var uploadingPhotos = ReactiveVar(); // upload indicator
Template.portfolioPhoto.helpers({
uploading: function() { return uploadingPhotos.get(); },
moreThanOne: function() { return uploadingPhotos.get() > 1 ? true : false; }
});
function uploadFiles(files, profileId) {
_.each(files, function(file) {
String.prototype.template = function (object) {
// Andrea Giammarchi - WTFPL License
var
stringify = JSON.stringify,
re = /\$\{(.*?)\}/g,
evaluate = [],
i = 0,
m
;
while (m = re.exec(this)) {