Skip to content

Instantly share code, notes, and snippets.

View orasik's full-sized avatar
🚴‍♂️
🏃‍♂️

Oras Al-Kubaisi orasik

🚴‍♂️
🏃‍♂️
View GitHub Profile
@orasik
orasik / main.go
Last active July 28, 2018 23:38
Go string vs buffer vs strings builder timings
package main
import (
"strings"
"bytes"
"fmt"
"time"
)
@orasik
orasik / decorators.py
Created May 28, 2018 15:08
Decorators example
def my_decortator(func):
def wrapper(*args):
print("Run before func")
func(*args)
print("Run after func")
return wrapper
def decorator_with_tags(tags):
@orasik
orasik / fake.py
Created May 8, 2018 16:24
Python Fake to generate random values
from faker import Faker
import json
fake = Faker('en_GB')
for i in range(50):
medicine = {
'name': fake.name(),
'manufacturer': fake.company(),
'country': fake.country(),
@orasik
orasik / graphene.py
Created May 4, 2018 09:29
Graphene Example
# Graphine Example
import graphene
import json
import string
import random
class User(graphene.ObjectType):
id = graphene.ID()
name = graphene.String()
@orasik
orasik / find_value.py
Created January 17, 2018 15:41
This script will search for a value in all columns in a MS-SQL db
# This script will search for a value in all columns in a MS-SQL db
# How to use:
# python find_value.py VALUE
# It will search for VALUE in every single column in DB and print the table, column and value when found
import sys
import pymssql
try:
# Populate your DB credentials
conn = pymssql.connect(
@orasik
orasik / go.sh
Created December 27, 2017 10:54
Go code analysis
#!/bin/bash
# Run this file inside your go project
# This will format your go files and write to them
gofmt -w *.go
# It will suggest style mistakes and missing docs, you'll need to manually fix them
# to install: go get -u github.com/golang/lint/golint
golint *.go
@orasik
orasik / config-validator.json
Created December 21, 2017 12:02
json schema
{
"title": "Person",
"type": "object",
"properties": {
"firstName": {
"type": "string"
},
"lastName": {
"type": "string"
},
@orasik
orasik / nltk.py
Last active December 19, 2017 22:09
NLTK
import nltk
sentence = """At eight o'clock on Thursday morning
... Arthur didn't feel very good."""
tokens = nltk.word_tokenize(sentence)
tokens
# >>> ['At', 'eight', "o'clock", 'on', 'Thursday', 'morning',
# >>> 'Arthur', 'did', "n't", 'feel', 'very', 'good', '.']
tagged = nltk.pos_tag(tokens)
tagged[0:6]
# >>> [('At', 'IN'), ('eight', 'CD'), ("o'clock", 'JJ'), ('on', 'IN'),
@orasik
orasik / requests.sh
Created December 15, 2017 15:29
Send n number of requests to API using CLI
# This will send 500 POST request to yourdomain.com
# this snippet can be used to send some data to your local dev API
for n in {1..500}; do curl -X POST \
http://yourdomain.com \
-H 'Cache-Control: no-cache' \
-H 'Content-Type: application/json' \
-d '{
"key" :"value"
}'; done
@orasik
orasik / kafka.md
Created December 15, 2017 15:26
Kafka Useful CLI Commands

Kafka CLI useful commands

List all messages in a topic from begining

kafka-console-consumer.sh --zookeeper {zookeeper-ip}:2181 --topic {topic-name} --from-beginning

Describe a topic