Skip to content

Instantly share code, notes, and snippets.

@candh
candh / schoolboy.js
Last active December 7, 2016 06:50
Basically replaces "h"s with "H"s. In honor of ScHoolboy Q's new album.
var vrse = "schoolboy" // insert verse here
var res = vrse.replace(/h/gi, "H");
console.log(res)
@candh
candh / random.js
Created August 26, 2016 17:27 — forked from kerimdzhanov/random.js
Javascript get random number in a specific range
/**
* Get a random floating point number between `min` and `max`.
*
* @param {number} min - min number
* @param {number} max - max number
* @return {float} a random floating point number
*/
function getRandom(min, max) {
return Math.random() * (max - min) + min;
}
@candh
candh / encrypt_decrypt_example.js
Last active January 31, 2017 12:11 — forked from erans/encrypt_decrypt_example.js
Example of encryption and decryption in node.js
var crypto = require("crypto")
function encrypt(key, data) {
var cipher = crypto.createCipher('aes-256-cbc', key);
var crypted = cipher.update(data, 'utf-8', 'hex');
crypted += cipher.final('hex');
return crypted;
}
@candh
candh / jpg-large2jpg.sh
Last active February 22, 2017 18:44
A simple bash script that converts all the files that it founds in a directory that ends with ".jpg-large" to ".jpg". Mainly made because when I download memes from twitter it converts them into .jpg-large and I really hate to convert them to .jpg for usage. It's literally hell when there's a lot of them. Not anymore!
#!/bin/bash
for i in `ls -a | grep .jpg-large$ | cut -d "." -f 1`;
do
mv ${i}.jpg-large ${i}.jpg
done;
echo "Bye 😘"
@candh
candh / vlcEvents.py
Created February 2, 2018 18:46
[vlc events example] This example checks if the song/media has stopped using the vlc's amazing python library. Also using pyqt here makes an event loop so be careful if you're running this without an event loop, the script will just quit! 🙂
from PyQt5.QtWidgets import *
import vlc
class App(QMainWindow):
def __init__(self):
super().__init__()
self.init()
def init(self):
@candh
candh / instructions
Last active March 10, 2018 14:05
php56 on mac os sierra with the apache2 server included with the OS
# install php56
$ brew tap homebrew/homebrew-php
$ brew install php56 --with-httpd
$ brew unlink httpd
# enabling sites folder
$ mkdir ~/Sites
# adding a ${USERNAME}.conf in /etc/apache2/users/
$ cd /etc/apache2/users
$ sudo nano username.conf
@candh
candh / fuckadobe.sh
Last active July 22, 2018 12:40
tired of adobe processes spawning up on boot? I am. kills more adobe processes with `sudo`.
#!/bin/bash
for e in $(ps A | grep "Adobe" | awk '{print $1}');
do
kill -9 $e
done
User-agent: ia_archiver
Disallow: /
@candh
candh / mipscheatsheet.md
Last active November 14, 2018 15:40
i made this so i dont have to look at others

MIPS cheatsheet

bold ones are important

R type instructions

Name OP Code Funct Instruction C equivalent
add 0 32 add $rd, $rs, $rt a = b + c
sub 0 34 sub $rd, $rs, $rt a = b - c
and 0 36 and $rd, $rs, $rt a = b & c