Skip to content

Instantly share code, notes, and snippets.

View DaCurse's full-sized avatar
😱

DaCurse

😱
View GitHub Profile
@DaCurse
DaCurse / enjoy_the_cancer.js
Last active December 15, 2022 16:11
Javascript date formatting
Date.prototype.dateNames = {};
Date.prototype.dateNames.days = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
Date.prototype.dateNames.shortDays = Date.prototype.dateNames.days.map(day => {
return day.substr(0, 3);
});
Date.prototype.dateNames.months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
Date.prototype.dateNames.shortMonths = Date.prototype.dateNames.months.map(month => {
return month.substr(0, 3);
});
@DaCurse
DaCurse / WebSocketFrame.js
Last active January 17, 2018 01:34
A websocket frame parser in javascript
class WSFrame {
constructor(buffer) {
if(buffer.byteLength < 2) {
throw new Error('Incomplete frame: Header data missing');
}
this.fin = 0;
this.opcode = 0;
this.mask = 0;
@DaCurse
DaCurse / DynamicArray.java
Created March 20, 2018 14:09
DynamicArray in java
public class DynamicArray<T> {
protected Object[] items;
// Empty dynamic array
public DynamicArray() {
items = new Object[] {};
}
// Copy another dynamic array
@DaCurse
DaCurse / genetic.c
Last active December 17, 2020 01:02
c - genetic string reversing
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#define MUTATE_RATE .01
#define BREED_RATE .75
#define POP_SIZE 10000
#define ELDERS_SIZE POP_SIZE * (1 - BREED_RATE)
@DaCurse
DaCurse / netstat_parser.py
Last active July 3, 2018 19:02
Python script that parses netstat -nb command in windows, getting current connnections & from which programs
from ctypes import windll
from sys import executable
from os import popen
def is_admin():
try:
return windll.shell32.IsUserAnAdmin()
except:
return False
@DaCurse
DaCurse / chinese_keyboard.ahk
Last active September 20, 2020 17:29
Make your keyboard only type regional indicators 🇯 🇺 🇸 🇹 🇱 🇮 🇰 🇪 🇹 🇭 🇮 🇸
Char_Count = 26
Loop, %Char_Count% {
Key := GetKeyName(Chr(A_Index + Asc("a") - 1))
Hotkey, %Key%, KeyHandler
}
Return
KeyHandler:
Start_Value := 0x1F1E6
@DaCurse
DaCurse / bcrypt.benchmark.ts
Created February 22, 2020 12:43
Simple benchmark to measure hash times of bcrypt.
import * as bcrypt from 'bcrypt';
function benchmarkHashSync(password, rounds) {
console.time('bcrypt-sync');
const salt = bcrypt.genSaltSync(rounds);
const hash = bcrypt.hashSync(password, salt);
console.timeEnd('bcrypt-sync');
console.log(hash);
}
@DaCurse
DaCurse / CustomThemeProvider.tsx
Last active September 15, 2021 06:13
A changeable theme context component for material-ui
import { createTheme, ThemeProvider } from '@material-ui/core/styles';
import React, { createContext, useEffect, useState } from 'react';
const darkTheme = createTheme({
palette: {
type: 'dark',
},
});
const lightTheme = createTheme({
palette: {
@DaCurse
DaCurse / github_tab_size.js
Created September 15, 2021 11:08
A UserScript to customize GitHub's tab size
// ==UserScript==
// @name Github Tab Size
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Changes GitHub's tab size
// @author DaCurse
// @match https://github.com/*
// @icon https://github.githubassets.com/favicons/favicon.svg
// @grant none
// ==/UserScript==