Skip to content

Instantly share code, notes, and snippets.

View pawel-dubiel's full-sized avatar

Pawel Dubiel pawel-dubiel

View GitHub Profile
double t = 0.0;
const double dt = 0.01;
double currentTime = hires_time_in_seconds();
double accumulator = 0.0;
State previous;
State current;
while ( !quit )
@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,
### Keybase proof
I hereby claim:
* I am pawel-dubiel on github.
* I am paweld (https://keybase.io/paweld) on keybase.
* I have a public key ASCpp9-PytysQjos85C369ICb2c50z_vQj9Y4-R-k6ZifQo
To claim this, I am signing this object:
@pawel-dubiel
pawel-dubiel / gist:30ad98fe3ef4f1baa3d3bbe0f020fabf
Created November 29, 2017 16:29 — forked from yunghoy/gist:a425f91824d26461bb2e3653bc56ebbf
AMQP library (RabbitMQ) - async/await
alias babel-node='babel-node --presets stage-0'
------ RECV ------
// babel-node recv2.js "#"
// babel-node recv2.js "kern.*"
const amqp = require('amqplib');
const args = process.argv.slice(2);
if (args.length == 0) {
//use script not recommended in es6 modules
export {average, sort_by_ranking_desc};
let items = [],max_test_items=10;
for ( let i=0;i<max_test_items;i++) {
items[i] = { name: "foo", ranking: Math.random() };
}
let sort_by_ranking_desc = (a, b) => (b.ranking-a.ranking );
@pawel-dubiel
pawel-dubiel / gist:b3b8c561ae3ee0e954f49ec44eea5ff7
Created April 17, 2017 21:59
javascript dom manipulation without jquery
function $(id) { return document.getElementById(id); }
function byClass (el, cl) { return el ? el.getElementsByClassName(cl) : [] }
function byTag (el, tg) { return el ? el.getElementsByTagName(tg) : [] }
function allof (cl) { return byClass(document, cl) }
function hasClass (el, cl) { var a = el.className.split(' '); return find(cl, a) }
function addClass (el, cl) { if (el) { var a = el.className.split(' '); if (!find(cl, a)) { a.unshift(cl); el.className = a.join(' ')}} }
function remClass (el, cl) { if (el) { var a = el.className.split(' '); rem(a, cl); el.className = a.join(' ') } }
function html (el) { return el ? el.innerHTML : null; }
function attr (el, name) { return el.getAttribute(name) }
function tonum (x) { var n = parseFloat(x); return isNaN(n) ? null : n }
@pawel-dubiel
pawel-dubiel / new_gist_file_0
Created March 19, 2016 22:11
Linux admin helper
get last top 10 ips from access log ( last 10000 requests )
tail -n 10000 access.log | awk '{print $1}' | sort | uniq -c | sort -n | tail -n 10
@pawel-dubiel
pawel-dubiel / magento_order_status_change.php
Created March 15, 2016 23:16
Magento change order status
<?php
require_once 'app/Mage.php';
Mage::app("default");
/**
*
* SELECT DISTINCT(status) FROM sales_flat_order ;
console.log("got here");
var page = require('webpage').create();
page.onConsoleMessage = function(msg) {
console.log(msg);
};
page.open("http://facebook.com", function(status) {
if ( status === "success" ) {
@pawel-dubiel
pawel-dubiel / gist:4520928
Created January 12, 2013 23:01
Fixed time step + rk4 integration
// from http://mndlss.com/2011/05/rk4-in-javascript/
/** EXAMPLE SETUP
**************************************************/
var ball = document.getElementById("ball")
, container = document.getElementById("cont")
, halfWidth = container.clientWidth / 2
, halfHeight = container.clientHeight / 2
, mouseUp = true
;
container.style.background = "rgb(185,195,159)";