Skip to content

Instantly share code, notes, and snippets.

View pawel-dubiel's full-sized avatar

Pawel Dubiel pawel-dubiel

View GitHub Profile
@pawel-dubiel
pawel-dubiel / gist:3707633
Created September 12, 2012 15:54
GitHub automatic deployment #github
try
{
$payload = json_decode($_REQUEST['payload']);
}
catch(Exception $e)
{
exit(0);
}
file_put_contents('logs/github.txt', print_r($payload, TRUE), FILE_APPEND);
@pawel-dubiel
pawel-dubiel / gist:3713813
Created September 13, 2012 11:48
#Iphone check the Private browsing is enabled
try {
localStorage.setItem('test', 'test');
} catch (err) {
if ((err.name).toUpperCase() == 'QUOTA_EXCEEDED_ERR') {
document.write('<div style="padding:5%;margin:5%;background:#777;color:white;height:90%">We don\'t seem to be able to store the information needed for this app to work on your phone.<br /><br /> It\'s probably because you have enabled private browsing mode. If you\'d like to disable private browsing go to settings section on your phone.</div>');
}
}
@pawel-dubiel
pawel-dubiel / gist:3714643
Created September 13, 2012 14:26
#Google #Maps #api constantly update user location on the map
/*global gmap */
function getUserLocation(map) {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function (position) {
var point = new google.maps.LatLng(position.coords.latitude,
position.coords.longitude);
if (typeof getUserLocation.user_marker == 'undefined') {
getUserLocation.user_marker = new google.maps.Marker({
position:point,
@pawel-dubiel
pawel-dubiel / gist:3737873
Created September 17, 2012 15:02 — forked from mrsweaters/gist:3157259
Stop words ( json )
[
"a",
"about",
"above",
"across",
"after",
"afterwards",
"again",
"against",
"all",
@pawel-dubiel
pawel-dubiel / gist:3775917
Created September 24, 2012 13:20 — forked from davidalexander/gist:1086455
Magento Snippets

Magento Snippets

Download extension manually using pear/mage

Pear for 1.4, mage for 1.5. File downloaded into /downloader/.cache/community/

./pear download magento-community/Shipping_Agent
./mage download community Shipping_Agent

Clear cache/reindex

@pawel-dubiel
pawel-dubiel / gist:3793211
Created September 27, 2012 09:55
#Nodejs ( #https, #request, #443, #HEADERS )
var https = require('https');
var options = {method: 'HEAD', host: 'user.tent.is', path: '/'};
var req = https.request(options, function(res) {
console.log(JSON.stringify(res.headers));
}
);
req.end();
req.on('error', function(e) {
@pawel-dubiel
pawel-dubiel / gist:3794328
Created September 27, 2012 14:34
Emulate slow internet connection: #Fedora, #OpenSuse, #Gentoo, #Debian, #Mandriva, #Ubuntu
add
sudo tc qdisc add dev eth0 root netem delay 250ms loss 20% reorder 25% 50%
-----------------------
change ( I need to edit this, just putting some examples for now )
tc qdisc change dev eth0 root netem delay 250ms loss 20% reorder 25% 50% )
tc qdisc change dev eth0 root netem gap 5 delay 100ms reorder 25% 69% loss 25% )
@pawel-dubiel
pawel-dubiel / gist:3802709
Last active October 11, 2015 04:27
Setting up a new domain #script
#!/bin/bash
echo "Enter a host name (e.g. example.com):";
read domain;
echo ""
echo 'IP ADDRESSES'
ifconfig | grep 'inet addr:'| grep -v '127.0.0.1' | cut -d: -f2 | awk '{ print $1}'
echo "Enter IP ADDRESS:";
read ipaddress;
@pawel-dubiel
pawel-dubiel / gist:3802890
Created September 29, 2012 01:52
Javascript optimisation
Some quick notes from http://www.youtube.com/watch?v=UJPdhx5zTaw
Don't mix types ( be sure the array is only of one type )
Don't read out of bounds
Avoid operations with undefined values ( always initialize )
Don't add a new properties to the object during runtime
Initialize all object members in constructor functions
Always initialize object members in the same order
Use 31 bit signed numbers in critical calculations
Don't preallocate arrays elements
Don't delete elements from arrays
@pawel-dubiel
pawel-dubiel / robot.js
Created December 4, 2012 19:31
basicus
//FightCode can only understand your robot
//if its class is called Robot
var Robot = function(robot) {
};
var save_gun_positon = '';
Robot.prototype.onIdle = function(ev) {