kafka-console-consumer.sh --zookeeper {zookeeper-ip}:2181 --topic {topic-name} --from-beginning
🚴♂️
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* This example is to inject object into the form type in order to generate entity field with related data only. Rather than loading the whole entity | |
* So if we have Order and we want to list its order lines. | |
* | |
* To call this code from Contoller | |
* | |
* $order = $this->getDoctrine()->getRepository('OrderBundle:Order')->find(100); | |
* $form = $this->createForm(new ReturnOrderType($order), $order); | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Goto a directory you can write to: | |
cd ~ | |
#get composer: | |
curl -s https://getcomposer.org/installer | php | |
# move composer into a bin directory you control: | |
sudo mv composer.phar /usr/local/bin/composer | |
# double check composer works | |
composer about |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This function basically will search for prices per hour in AWS webpage and replace it with Monthly price | |
function findAndReplace(tag) { | |
var content = document.getElementsByTagName(tag)[0].innerHTML; | |
// This pattern will search for strings like `$0.023 per Hour` | |
var pattern = /\$\d+\.\d+\sper\sHour/g; | |
content = content.replace(pattern, | |
function(entry) { | |
// This will extract float value only | |
pattern = /\d+\.\d+/g | |
return '$'+ 24 * 30 * parseFloat(entry.match(pattern)) + ' per Month' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/^\[(?<timestamp>[\d\-]+ [\d\:]+)\] (?<log_name>.+)\.(?<log_level>(DEBUG|INFO|NOTICE|WARNING|ERROR|CRITICAL|ALERT|EMERGENCY))\: (?<message>.*) (?<context>\{.+\}) \[(?<extra>.*)\]$/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Code to test if theano is using GPU or CPU | |
# Reference: https://stackoverflow.com/questions/34328467/how-can-i-use-my-gpu-on-ipython-notebook | |
from theano import function, config, shared, sandbox | |
import theano.tensor as T | |
import numpy | |
import time | |
vlen = 10 * 30 * 768 # 10 x #cores x # threads per core | |
iters = 1000 | |
rng = numpy.random.RandomState(22) | |
x = shared(numpy.asarray(rng.rand(vlen), config.floatX)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* The following code will replace array that has values equalt to keys in another one. | |
* Example: | |
* $config = [ | |
* 'key1' => 'value1', | |
* 'key2' => 'value2', | |
* 'subkeys' => [ | |
* 'subkey1' => 'subvalue1', | |
* 'subkey2' => 'subvalue2' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Showing openCV version | |
import cv2 | |
print("OpenCV version: %s" % cv2.__version__) | |
# Reading image and converting it to HSV | |
img = cv2.imread('img/test.jpg') | |
img = cv2.cvtColor(img, cv2.COLOR_BGR2HSV ) | |
plt.imshow(img) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# I wrote this code to draw a box on image using yolo2 format | |
# Yolo2 format: <object-class> <x> <y> <width> <height> | |
# reference: https://pjreddie.com/darknet/yolo/ | |
# I use this code to make sure I've converted x1,y1 x2,y2 format to yolo2 format correctly by plotting the box on images. | |
import skvideo.io | |
import matplotlib.pyplot as plt | |
import sys | |
import os | |
import cv2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Run this code inside your app code | |
# /go/src/app <- is the location of your app inside the container | |
# if you use /go or /go/src it will not compile and you'll get error: no install location for directory outside GOPATH | |
# you can change `app` to any name though | |
# This will build binary for linux, you can change to Windows or Mac by changing GOARCH | |
# Check a full list of GOARCH and GOOS here: https://gist.github.com/asukakenji/f15ba7e588ac42795f421b48b8aede63 | |
docker run --rm -v "$PWD":/go/src/app -w /go/src/app golang:1.9 go get -v && GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build . |
OlderNewer