Skip to content

Instantly share code, notes, and snippets.

View hmenn's full-sized avatar
🎧
Focusing

Hasan MEN hmenn

🎧
Focusing
View GitHub Profile
@hmenn
hmenn / tsafequeue.hpp
Created February 22, 2019 08:23
Basic thread safe queue
#include <iostream>
#include <thread>
#include <mutex>
#include <queue>
#include <chrono>
template <class T>
class TSafeQueue{
public:
TSafeQueue(){
@hmenn
hmenn / reverse_string.cpp
Created February 8, 2019 20:22
reserse a string in cpp
#include <iostream>
#include <string>
std::string reverse(std::string str){
if(str.empty()){
return "";
}
int last_elem_index=str.size()-1;
return str[last_elem_index] + reverse(str.substr(0, last_elem_index));
}
@hmenn
hmenn / wpa_supplicant.conf
Last active January 15, 2019 14:43
wpa_supplicant.conf
country=us
update_config=1
ctrl_interface=/var/run/wpa_supplicant
# Create a new one with "wpa_passphrase NAME PASS"
network={
ssid="NAME"
#psk="PASS"
psk=cfe117ff936f870afaa2fbb5b6c21aca8
key_mgmt=WPA-PSK
@hmenn
hmenn / 12d1:1f1c
Created December 24, 2017 13:20 — forked from ryankurte/12d1:1f1c
Enable Huawei K4203 Cellular Internet dongle on Linux
TargetVendor=0x12d1
TargetProduct=0x1f1c
MessageContent="55534243123456780000000000000011062000000101000100000000000000"
@hmenn
hmenn / .zshrc
Created December 13, 2017 19:01
My configured zshrc
# If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:/usr/local/bin:$PATH
# Path to your oh-my-zsh installation.
export ZSH=/home/hmenn/.oh-my-zsh
# Set name of the theme to load. Optionally, if you set this to "random"
# it'll load a random theme each time that oh-my-zsh is loaded.
# See https://github.com/robbyrussell/oh-my-zsh/wiki/Themes
ZSH_THEME="robbyrussell"
@hmenn
hmenn / SIM900.py
Created November 12, 2017 12:36
SIM900 Arduino GSM Shield with Raspberry 3
import time
import serial
class SIM900:
def __init__(self, port, baudrate,timeout):
self.mPort = port
self.mPBaudrate=baudrate
self.mTimeout=timeout
def connect(self):
@hmenn
hmenn / bracket_validator.py
Created July 12, 2017 20:07
Interview_cake_147_bracket_validator
open_brackets =['{','[','(']
close_brackets = ['}',']',')']
def getIndex(l,ch):
index=None
try:
index=l.index(ch)
except:
index=None
#from http://www.pyimagesearch.com/2015/03/30/accessing-the-raspberry-pi-camera-with-opencv-and-python/
# import the necessary packages
from picamera.array import PiRGBArray
from picamera import PiCamera
import time
import cv2
# initialize the camera and grab a reference to the raw camera capture
camera = PiCamera()
@hmenn
hmenn / wpa_supplicant.conf
Created July 1, 2017 13:58
Example wpa_supplicant.conf
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
network={
ssid="Example_WEP_Network"
scan_ssid=1
key_mgmt=NONE
wep_key0="wep_password"
wep_tx_keyidx=0
}
@hmenn
hmenn / getPropertiesFromFile.java
Created February 1, 2017 22:45
read properties file in Java
public Properties getPropertiesFromFile(String fileName) {
Properties properties = null;
try {
properties = new Properties();
properties.load(getClass().getClassLoader().getResourceAsStream(fileName));
} catch (IOException e) {
System.err.println("Error detected");
e.printStackTrace();
}
return properties;