Skip to content

Instantly share code, notes, and snippets.

@Yengas
Yengas / Encrypt.ts
Created May 19, 2018 17:16
Cross platform (react native, web, node) aes/triple des encryption and decryption with crypto-js
import { AES, TripleDES, lib, mode, CipherOption, Cipher } from 'crypto-js';
import { BinaryFormatter, wordArrayToUint8Array } from './utils';
export enum EncryptionAlgorithm{
AES = 0,
TripleDES = 1,
}
//const options = { padding: pad.ZeroPadding, mode: mode.CBC };
const options = {
[EncryptionAlgorithm.TripleDES]: {
@Yengas
Yengas / promise.js
Last active May 19, 2018 18:56
A promise implementation without any spec compliance. Just for fun.
class MyPromise{
// create a new instance of a promise
// callback is a function that accepts resolve and reject functions as params
constructor(callback){
this.resolved = false;
this.reject = false;
this.value = null;
// to temporarily hold promises that got created while this promise was in pending state
this.waiting = [];
@Yengas
Yengas / homography-rotate.py
Created April 11, 2018 22:40
Multiplying two homography with opencv python. Combining two homography so the output will be rotated
# Rotates the given homography from the origin point
def getRotatedHomography(homography, size, angle):
width, height = size
rotation = cv2.getRotationMatrix2D((width / 2, height / 2), angle, 1)
rotationHomography = np.concatenate((rotation, np.array([[0, 0, 1]])))
return np.dot(rotationHomography, homography)
@Yengas
Yengas / videostab.py
Last active March 21, 2025 20:03
Video Stabilization with Python3.5 and OpenCV3 following chen jia's cpp implementation.
#!/usr/bin/python3.5
import sys
import argparse
import cv2
from math import atan2, cos, sin
import numpy as np
# this class is based on the code of Nghia Ho who first coded it for video files
# and the code of chen jia who added kalman filter for live features.
# see http://nghiaho.com/uploads/videostabKalman.cpp
@Yengas
Yengas / cqlsh-import-csv-gz.sh
Last active November 15, 2020 09:07
Cassandra CSV import with GZIP compression
(echo "COPY flat.data (metric, resource, domain, timestamp, longvalue, doublevalue, textvalue) FROM STDIN;"; \
gzip -dc flat-data-*.csv.gz;) | cqlsh
@Yengas
Yengas / f0rtig8.sh
Last active March 20, 2017 16:00
Trakya Üniversitesi Fortigate Authentication Otomatikleştirme. Kısaca: bash script ile internet bağlantısını aktif tutma. $USER kısmına mail adresinizin @'den öncesini, $PASSWORD kısmına şifrenizi girin.
#!/bin/bash
IP=10.40.254.2
PORT=1000
SLEEP_TIME=5
USER="USER"
PASSWORD="PASS"
# Color and info
RED='\033[0;31m'
GREEN='\033[0;32m'
CYAN='\033[0;36m'
@Yengas
Yengas / README.md
Last active April 4, 2025 08:30
Creating Table of Contents by reading the folder and file structure of a git project

toc.py

This script reads the structure of your git project to create a markdown table of contents. You can use the output of this script to add a TOC to the README of your project.

Example folder structure:

.
├── Test
│   └── README.md
├── Test2
│   ├── README.md
@Yengas
Yengas / countries_and_cities.json
Created December 14, 2016 08:14
Türkçe isimli ülke ve şehirler. 2 Karakterli iso kodları ile birlikte.
[{"code": "AF", "cities": ["As\u00e2d\u00e2b\u00e2d", "\u00c2ybak", "Baghl\u00e2n", "Balkh", "B\u00e2m\u00eey\u00e2n", "Chaghchar\u00e2n", "Ch\u00e2r\u00eek\u00e2r", "Far\u00e2h", "Fayz\u00e2b\u00e2d", "Ghardez", "Ghazni", "Her\u00e2t", "Jal\u00e2l\u00e2b\u00e2d", "K\u00e2bul", "Kh\u00e2n\u00e2b\u00e2d", "Khawst", "Kholm", "Lashkar G\u00e2h", "Mahm\u00fbd-e R\u00e2q\u00ee", "Mayd\u00e2nshahr", "Maym\u00e2nah", "Maz\u00e2r-e Shar\u00eef", "Mehtar L\u00e2m", "N\u00fbrist\u00e2n", "Pol-e Alam", "Pol-e Khumri", "Qal\u00b4eh-ye Naw", "Qal\u00e2t-e Ghilzay", "Qandah\u00e2r", "Qund\u00fbz", "Sar-e Pul", "Shibarghan", "T\u00e2loq\u00e2n", "Tar\u00een Kawt", "Zaranj", "Zareh Sharan"], "country": "Afganistan"}, {"code": "AL", "cities": ["Bajram Curri", "Ballsh", "Berat", "Bilisht", "Bulqiz\u00eb", "Burrel", "\u00c7orovod\u00eb", "Delvin\u00eb", "Durr\u00ebs", "Elbasan", "Ersek\u00eb", "Fier", "Gjirokast\u00ebr", "Gramsh", "Kavaj\u00eb", "Koplik", "Kor\u00e7\u00eb", "Kruj\u00eb", "Krum\u00eb", "Ku\u00e7ov\u00eb", "Kuk\u
@Yengas
Yengas / TubitEgitim.cs
Created December 7, 2016 16:03
7 Aralıık 2016 Tübit eğitimi; Arama ve Sıralama algoritmaları
#include <stdio.h>
#include <stdlib.h>
// O(n) ==> n = length
int linear_search(int value, int* arr, int length){
for(int i = 0; i < length; i++)
if(arr[i] == value)
return 1;
return 0;
}
@Yengas
Yengas / jazzradio.bat
Last active October 5, 2016 14:15
Jazz Radio custom player
set STATION="fusionlounge"
IF NOT "%1"=="" (
set STATION=%1
)
echo "JazzRadio.com - %STATION%"
mpv "http://pub6.jazzradio.com/jr_%STATION%_aacplus?type=.flv" --http-header-fields="User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.101 Safari/537.36","Referer: http://www.jazzradio.com/%STATION%","X-Requested-With: ShockwaveFlash/22.0.0.209","Connection: keep-alive"