Skip to content

Instantly share code, notes, and snippets.

View alhafoudh's full-sized avatar

Ahmed Al Hafoudh alhafoudh

View GitHub Profile
const _ = require('lodash');
function printKeys(key, obj, parentKeyPath = '') {
const keyPath = `${parentKeyPath}.${key}`;
console.log(keyPath);
if (_.isArray(obj) && !_.isEmpty(obj)) {
printKeys(key, _.head(obj), keyPath);
} else if (_.isObject(obj)) {
const firstKey = _.head(_.keys(obj));
@alhafoudh
alhafoudh / Config.java
Created February 4, 2017 11:47
Spring multiple data sources
package sk.freevision.probase.config;
import org.springframework.context.annotation.Configuration;
@Configuration
//@EnableAutoConfiguration(exclude={DataSourceAutoConfiguration.class})
public class Config {
// @Bean(name = "metaDataSource")
// @Primary
@alhafoudh
alhafoudh / build.gradle
Created July 14, 2016 17:56
Gradle file for backendless hosted service
group 'sk.freevision.myservice'
version '1.0.0-SNAPSHOT'
apply plugin: 'java'
sourceCompatibility = 1.8
repositories {
mavenCentral()
}
<?xml version="1.0" ?>
<device>
<deviceProtocol>SIP</deviceProtocol>
<sshUserId>root</sshUserId>
<sshPassword>cisco</sshPassword>
<devicePool>
<dateTimeSetting>
<dateTemplate>M/D/YA</dateTemplate>
<timeZone>Central Standard/Daylight Time</timeZone>
<ntps>
root@ip-172-31-6-203:/var/lib/docker# cat repositories-aufs
{"Repositories":{}}
root@ip-172-31-6-203:/var/lib/docker# cat repositories-devicemapper
{"Repositories":{"freevision/phantomjs":{"latest":"596c486eb6cdc0a05b9911b2f0c07c3ef9827871513a5e798cb248e0190b01eb"}}}
root@ip-172-31-6-203:/var/lib/docker# docker images -a
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
exports.handler = function(event, context) {
for (var i in event.Records) {
var record = event.Records[i];
console.log("Processing record");
var data = new Buffer(record.kinesis.data, 'base64').toString();
console.log("Input data: " + data);
var http = require('http');
@alhafoudh
alhafoudh / logstash_docker.conf
Created August 23, 2014 22:11
Logstash watch docker logs
input {
file {
codec => json
path => '/var/lib/docker/containers/*/*-json.log'
}
}
filter {
ruby {
code => "Thread.current[event['path']] ||= JSON.parse(Pathname(event['path']).dirname.join('config.json').read)"
}

Keybase proof

I hereby claim:

  • I am alhafoudh on github.
  • I am alhafoudh (https://keybase.io/alhafoudh) on keybase.
  • I have a public key whose fingerprint is 0770 2ACB 3379 C475 6B3F CCD1 39AC A456 B7EC D57B

To claim this, I am signing this object:

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
require 'sidetiq'
Sidekiq.configure_client do |config|
config.redis = { namespace: 'x', size: 1 }
end
# Sidekiq server is multi-threaded so our Redis connection pool size defaults to concurrency (-c)
Sidekiq.configure_server do |config|
config.redis = { namespace: 'x' }
end