Skip to content

Instantly share code, notes, and snippets.

View lotas's full-sized avatar
🏠
Working from home

Yarik lotas

🏠
Working from home
View GitHub Profile
@lotas
lotas / PA_F2fUp.php
Created October 10, 2011 09:20
simple feature processing
class Yangutu_Payment_Action_F2fUp extends Yangutu_Payment_Action_Simple
{
protected $defaultReturnUrl = '/face-to-face';
protected $message = 'You are now promoted in face-to-face';
}
@lotas
lotas / gist:1681615
Created January 26, 2012 07:59 — forked from remy/gist:350433
Storage polyfill
if (typeof window.localStorage == 'undefined' || typeof window.sessionStorage == 'undefined') (function () {
var Storage = function (type) {
function createCookie(name, value, days) {
var date, expires;
if (days) {
date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));
expires = "; expires="+date.toGMTString();
@lotas
lotas / Zend_Mime.php
Created July 20, 2012 11:04
Zend mime
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
@lotas
lotas / Xml.php
Created August 29, 2012 08:39
array_to_xml.php
<?php
class Yangutu_Util_Xml
{
public static function arrayToXml(array $array, $attrTypeMap = array(), $returnAsString = true)
{
$xml = new SimpleXMLElement("<?xml version=\"1.0\"?><transaction></transaction>");
#!/bin/bash
# MySQL root password
ROOTPASS="password"
TIMEZONE="Europe/Moscow"
MYSQLPASS=`< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c12`
SFTPPASS=`< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c12`
##############
@lotas
lotas / fill_table.py
Created June 14, 2013 10:57
>python fill_table.py database table_name 20 [ Really dump script to fill the void of mysql tables. Will create 20 records with in *database.table_name* table with random data (depending on column type) ]
import re
import sys
import random
import string
import numpy as np
import MySQLdb
import MySQLdb.cursors
DB_HOST = "localhost"
DB_USER = "root"
@lotas
lotas / p_sha1.php
Created October 24, 2013 21:51
p-sha1 in php
<?php
$secret = base64_decode('kAIthWJeZ3UoS4k6qLIbfA==');
$label = base64_decode('L3JLyhzv0VTomcnzcDjoAhaMNCk=');
$seed = base64_decode('yP9lu4OUF1ah534Re/ZfcQ==');
$newSeed = $label . $seed; // concat as strings
$length = 16;
// $p_sha1
@lotas
lotas / autocomplete.js
Created October 25, 2013 08:03
autocomplete.js angular bootstrap-ui
autocomplete.directive('suggest', ['$compile', 'AutocompleteService', function ($compile, AutocompleteService) {
var cnt = 0;
return {
require: '',
restrict: 'A',
replace: true,
transclude: true,
template: '<input ng-transclude type="text" autocomplete="off" typeahead="item for item in items" />',
compile: function (elm, attrs) {
@lotas
lotas / directive.js
Created October 25, 2013 11:43
Autocomplete with directive stacking
autocomplete.directive('typeahead', ['$compile', 'AutocompleteService', function ($compile, AutocompleteService) {
return {
restrict: 'A',
priority: 999,
link: function ($scope, elm, attrs) {
$scope.getItems = function (filter, type, autocompletItems) {
var fn = AutocompleteService.getLookupFunction(type, autocompletItems);
return fn(filter);
}
}
@lotas
lotas / fetch.js
Last active December 28, 2015 02:49
Fetch & parse radio song details, save in mongodb database To generate some stats and remember which song played a while ago ;)
var http = require('http'),
xml2js = require('xml2js'),
MongoClient = require('mongodb').MongoClient;
var reqOptions = {
host: "streamdb4web.securenetsystems.net",
port: 80,
path: "/player_status_update/KMYZ.xml?randStr=",
method: "GET"
};