Skip to content

Instantly share code, notes, and snippets.

View amad's full-sized avatar
🚀
(⌐■_■)

Ahmad Samiei amad

🚀
(⌐■_■)
View GitHub Profile
<?php
// Variables used in this script:
// $summary - text title of the event
// $datestart - the starting date (in seconds since unix epoch)
// $dateend - the ending date (in seconds since unix epoch)
// $address - the event's address
// $uri - the URL of the event (add http://)
// $description - text description of the event
// $filename - the name of this file for saving (e.g. my-event-name.ics)
//
@amad
amad / .vimrc
Created April 20, 2014 19:57 — forked from JeffreyWay/.vimrc
set nocompatible " Disable vi-compatibility
set t_Co=256
colorscheme xoria256
set guifont=menlo\ for\ powerline:h16
set guioptions-=T " Removes top toolbar
set guioptions-=r " Removes right hand scroll bar
set go-=L " Removes left hand scroll bar
set linespace=15
window.addEventListener('devicelight', function(e) {
var lux = e.value;
document.querySelector('#result').textContent = lux + ' lux';
if(lux < 50) {
document.body.className = 'dim';
}
if(lux >= 50 && lux <= 1000) {
document.body.className = 'normal';
}
/**
* _demonlib.php
*/
defined('DEAMON_LOCK_FILE') ||
define('DEAMON_LOCK_FILE', 'run/deamon.pid');
if($_SERVER['argc'] >= 2 && $_SERVER['argv'][1] == 'kill')
{
$fh = fopen(realpath(__DIR__) . '/' . DEAMON_LOCK_FILE, 'r');
$ stty -F /dev/ttyACM0 cs8 9600 ignbrk -brkint -imaxbel -opost -onlcr -isig\
-icanon -iexten -echo -echoe -echok -echoctl -echoke noflsh -ixon -crtscts
$ screen /dev/ttyACM0 9600
<?php
<?php
// Turn off output buffering
ini_set('output_buffering', 'off');
// Turn off PHP output compression
ini_set('zlib.output_compression', false);
//Flush (send) the output buffer and turn off output buffering
while (@ob_end_flush());
@amad
amad / leave_detect.js
Created November 1, 2013 12:31
non standard event for detect user leaving
window.onbeforeunload = function() { return "Message"; };
setlocale(LC_ALL, 'en_US.UTF8');
function toAscii($str, $replace=array(), $delimiter='-') {
if( !empty($replace) ) {
$str = str_replace((array)$replace, ' ', $str);
}
$clean = iconv('UTF-8', 'ASCII//TRANSLIT', $str);
$clean = preg_replace("/[^a-zA-Z0-9\/_|+ -]/", '', $clean);
$clean = strtolower(trim($clean, '-'));
$clean = preg_replace("/[\/_|+ -]+/", $delimiter, $clean);
<?php
function shutdown_find_exit()
{
var_dump($GLOBALS['dbg_stack']);
}
register_shutdown_function('shutdown_find_exit');
function write_dbg_stack()
{
$GLOBALS['dbg_stack'] = debug_backtrace();
@amad
amad / gridComputingOnTheWeb.js
Created August 27, 2013 05:05
Grid computing matrix process
var socket = io.connect('http://grid.moeinhm.ir:3000');
var GridTask = new Worker('matrix.js');
GridTask.postMessage('doIt');
GridTask.onmessage = function(result){
socket.emit('result',result);
GridTask.postMessage('doIt');
};
GridTask.onmessage(result);