Skip to content

Instantly share code, notes, and snippets.

View pawel-dubiel's full-sized avatar

Pawel Dubiel pawel-dubiel

View GitHub Profile
### 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 ;
@pawel-dubiel
pawel-dubiel / 0_reuse_code.js
Last active August 29, 2015 14:24
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console

I have managed to install this… and make it work. I implemented it for Facebook and Google, but you can extend it. My solution it is mostly as described in #116, with a bit of more code presented. The key aspects that lack in the #116 presentation (IMO) are:

  • the registration as service of your custom FOSUBUserProvider (with the necessary parameters)
  • set the service for oauth_user_provider in the security.yml with your custom created service

Here are the steps:

  1. Routing. In routing.yml I have added all the routes for both bundles.
  2. Configuration. I have set the config.yml mostly as it is presented in the HWIOAuthBundle.
  3. Security. I have set the security.yml mostly as it is presented in the HWIOAuthBundle (though my routes are using /login pattern, not /connect). Also, the oauth_user_provider is set for my custom service.
:new will create a split window with an unnamed buffer.
:enew will open one in the current window.
:vnew will open one in a vertically split window.
:tabnew will open one in a new tab.
Next tab: gt
#!/bin/bash
#count_email_log
#add to cron
#59 23 * * * root /bin/count_email_log
IFS='%'
touch /var/www/mail.txt || exit
VOUTME="$(mktemp)"
VCURRENTDATE=$(date "+%b %-d")
VCURRENTDATEFULL=$(date "+%b.%-d.%y")