Skip to content

Instantly share code, notes, and snippets.

View erancihan's full-sized avatar

Cihan Eran erancihan

View GitHub Profile
@erancihan
erancihan / release-my-port.ps1
Created August 3, 2023 14:13
RELEASE MY PORT -- when you cannot connect to a specific WSL2 port because reasons
# originally from:
# https://dev.to/wetterkrank/wsl2-localhost-3000-issue-191b#comment-1gg56
$addr='0.0.0.0';
$port=3000;
iex "netsh interface portproxy delete v4tov4 listenport=$port listenaddress=$addr";
@erancihan
erancihan / automatic1111.sh
Last active August 4, 2023 13:17
A script to setup AUTOMATIC1111's "stable-diffusion-webui"
#!/bin/bash
# This is a script to both install and run the Stable Diffusion WebUI by AUTOMATIC1111.
# Script will first check if the webui is installed, if not it will install it.
# Then it will check for updates and run the webui's webui.sh script.
#
# Usage:
# -p [value], --path [value] :
# Install Automatic1111's Stable Diffusion Webui repo to a custom path.
# You will not need to set this path every time you want to run this script,
@erancihan
erancihan / alacritty-key-bindings.yml
Created August 9, 2022 08:32
Alacritty Turkish-Q Keybind Config
# You cannot directly use this file.
# Copy below into your ~/.config/alacritty/alacritty.yml file,
# under correct location.
key_bindings:
# Common QoL
- {
key: Comma,
mods: Command,
command:
@erancihan
erancihan / fun_w_go_tags.go
Created September 22, 2021 07:35
A script to play around to see how you can work with Go Tags & Structs
package main
import (
"fmt"
"reflect"
)
type Model struct {
FieldA string `custom:"field_a" json:"out_a"`
FieldB int `custom:"field_b" json:"out_b"`
@erancihan
erancihan / pre-commit
Last active April 12, 2021 23:33
Simple GIT pre-commit hook for linting
#!/usr/bin/env bash
echo "> Running pre-commit script"
PWD=$(pwd)
BIN_PRETTIER="$PWD/node_modules/prettier/bin-prettier.js"
mapfile files < <(git diff-index --diff-filter=d --cached --name-only HEAD)
files_c=${#files[@]}
@erancihan
erancihan / drop.js
Created March 16, 2021 16:51
MongoDB Drop Duplicate entries
db.MyCollection.aggregate([
{
$group: {
_id: "$col",
duplicates: { $addToSet: "$_id" },
count: { $sum: 1 },
},
},
{ $match: { count: { $gt: 1 } } },
])
@erancihan
erancihan / proxy.go
Created April 20, 2020 17:38
simple subdomain based Proxy to a url
package main
import (
"github.com/labstack/echo"
"github.com/labstack/echo/middleware"
"net/url"
"strings"
)
var ServerPort = ":8000"
import javax.crypto.SecretKeyFactory;
import javax.crypto.spec.PBEKeySpec;
import java.nio.charset.StandardCharsets;
import java.security.NoSuchAlgorithmException;
import java.security.spec.InvalidKeySpecException;
import java.security.spec.KeySpec;
import java.util.Base64;
public class Salter {
public static void main(String[] args)
import java.util.Random;
// Java program to demonstrate the usage of
// setDaemon() and isDaemon() method.
public class DaemonThread extends Thread
{
public DaemonThread(String name) {
super(name);
}
@erancihan
erancihan / shuffle.php
Created June 13, 2018 16:46
a PHP script to compare time consumption between built in shuffle and seeded shuffle
<?php
$ans1 = json_decode("{ \"id\": 503732, \"question_id\": 129290, \"title\": \"Hemen hemen her gün yorgunum\", \"link\": null, \"background\": \"\", \"vote_count\": 757, \"created_at\": \"2018-01-30 15:06:05\", \"updated_at\": \"2018-01-30 15:45:24\", \"triggers_lead\": 0, \"cm_question_id\": 129294, \"triggers_display\": 0, \"has_right_answer\": 0, \"is_right_answer\": 0, \"voted\": 0 }");
$ans2 = json_decode("{ \"id\": 503733, \"question_id\": 129290, \"title\": \"Haftada en az 3-4 gün yorgunum\", \"link\": null, \"background\": \"\", \"vote_count\": 262, \"created_at\": \"2018-01-30 15:06:05\", \"updated_at\": \"2018-01-30 15:45:24\", \"triggers_lead\": 0, \"cm_question_id\": 129294, \"triggers_display\": 0, \"has_right_answer\": 0, \"is_right_answer\": 0, \"voted\": 0 }");
$ans3 = json_decode("{ \"id\": 503734, \"question_id\": 129290, \"title\": \"Haftada 1-2 gün yorgunum\", \"link\": null, \"background\": \"\", \"vote_count\": 199, \"created_at\": \"2018-01-30 15:06:05\", \"updated_at\": \"2018-01-