Skip to content

Instantly share code, notes, and snippets.

View asjustas's full-sized avatar

Justas asjustas

  • Vilnius, Lietuva
View GitHub Profile
@asjustas
asjustas / gist:7409287
Created November 11, 2013 07:32
Select where in and order by in
SELECT * FROM table WHERE id IN (118,17,113,23,72) ORDER BY FIELD(id,118,17,113,23,72)
<?php
function getSerie($type, $save = false) {
global $reg;
switch($type) {
case 'shipments':
$id = 17;
break;
case 'drivers':
@asjustas
asjustas / gist:6761802
Created September 30, 2013 10:10
Eval js
var theInstructions = "alert('Hello World'); var x = 100";
var F = new Function (theInstructions);
return(F());
@asjustas
asjustas / gist:6548088
Created September 13, 2013 08:32
overwrite onclick
$('.btn-group a').each(function(){
$(this).data('onclick', this.onclick);
this.onclick = function(event) {
return false;
//$(this).data('onclick').call(this, event || window.event);
};
});
@asjustas
asjustas / gist:5797645
Created June 17, 2013 15:10
FullCalendar.js normal date format
var formatDate = function(dateString) {
var parsedDate = $.fullCalendar.parseDate(dateString);
return $.fullCalendar.formatDate(parsedDate, 'dddd d MMMM yyyy',options);
}
@asjustas
asjustas / gist:5797631
Created June 17, 2013 15:09
seconds to time format
<?php
$sek = x;//laikas sekundemis
$dt = new DateTime('@'.$sek, new DateTimeZone('UTC'));
$plannedHours = ($dt->format('z')*24 + $dt->format('G')).":".$dt->format('i'); //turetu rodyti kitokiu formatu t.y. ir dienas
var errorLog = function errorLog(msg, url, line) {
var i = document.createElement('img');
i.src = '/error/log?msg=' + encodeURIComponent(msg) + '&url=' + encodeURIComponent(url) + '&line=' + encodeURIComponent(line);
};
window.onerror = errorLog;
@asjustas
asjustas / gist:5363442
Created April 11, 2013 13:38
websocket basic
var connection = new WebSocket('ws://127.0.0.1:1337');
connection.onopen = function () {
// first we want users to enter their names
input.removeAttr('disabled');
status.text('Choose name:');
};
connection.onerror = function (error) {
// just in there were some problems with conenction...
@asjustas
asjustas / gist:5247134
Created March 26, 2013 17:03
Change open files limit centos
$ ulimit -n
4096
$ ulimit -n 8192
bash: ulimit: open files: cannot modify limit: Operation not permitted
$ sudo bash
# ulimit -n
4096
# ulimit -n 8192
# su - normaluser
$ ulimit -n
@asjustas
asjustas / gist:5005274
Last active December 14, 2015 01:19
recurse array function
recurse_func = function(arr, callback, delay) {
if (typeof(callback) == "function") {
delay = delay || 200;
var self = arr, idx = 0;
setInterval(function() {
callback(self[idx], idx);
idx = (idx+1 < self.length) ? idx+1 : 0;
}, delay);
}