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
You appear to be advocating a new:
[ ] cloud-hosted [ ] locally installable [ ] web-based [ ] browser-based [ ] language-agnostic
[ ] language-specific IDE. Your IDE will not succeed. Here is why it will not succeed.
You appear to believe that:
[ ] Syntax highlighting is what makes programming difficult
[ ] Garbage collection is free
[ ] Computers have infinite memory
[ ] Nobody really needs:
# Username/password example
# DAEMON_ARGS="-b -t -a \"*.*.*.*\" -e /var/log/transmission/transmission.log"
# No username/password, but limited to 192.168.1.*
# DAEMON_ARGS="-b -T -a \"192.168.1.*\" -e /var/log/transmission/transmission.log"
INTERFACE=ppp0
if ifconfig $INTERFACE >>/dev/null 2>&1; then
BIND_ADDR="`/sbin/ifconfig $INTERFACE | awk '$1 == \"inet\" {print $2}' | awk -F: '{print $2}'`"
@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"
};
@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 / 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 / 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 / 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"
#!/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 / 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>");
@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