Skip to content

Instantly share code, notes, and snippets.

View codeniko's full-sized avatar

Nikolay Feldman codeniko

View GitHub Profile
@codeniko
codeniko / rsync_backup.sh
Last active August 29, 2015 14:01
Shell script to backup home directory and /usr/local/bin to a FAT32 device (daily cron)
#!/bin/sh
mnt=/mnt/codeniko
mntWindows=/mnt/windows
dev=/dev/sdb1
devWindows=/dev/sda1 # OPTIONAL for useful files on windows partition
log=/var/log/codeniko_backup
excl=/home/niko/.rsync_backup_exclude.lst
incl=/home/niko/.rsync_backup_include.lst
@codeniko
codeniko / aget
Last active July 20, 2022 19:38
'Audio'get using youtube-dl. Like wget, except for extracting and saving audio from music/audio videos
#!/bin/bash
# DEPENDENCIES
# apt-get install ffmpeg id3v2
# install youtube-dl from github
# trim a filepath to only get filename, ${1} is filepath
function trimFilename
{
last=0
@codeniko
codeniko / brightness.c
Created May 16, 2014 02:51
C program to modify the brightness on laptops running Linux distributions.
/* Brightness.c
Modify the brightness on laptop running a linux distro. You need root privileges to run as it read/writes to /sys/class/backlight/intel_backlight/brightness.
To avoid the password prompt for something as trivial as this, the setuid permission bit wouldn't hurt.
Chown root:user and chmod 4750 suggested
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
@codeniko
codeniko / keygen.cpp
Created May 16, 2014 03:28
Create random password keys of argument length
#include <stdlib.h>
#include <chrono>
#include <iostream>
#include <random>
#include <string>
#include <sstream>
#define NUMKEYS 71
static char keys[] = {'a', 'b', 'c' ,'d' ,'e' ,'f' ,'g' ,'h' ,'i' ,'j' ,'k' ,'l' ,'m' ,'n' ,'o' ,'p' ,'q' ,'r' ,'s' ,'t' ,'u' ,'v' ,'w' ,'x' ,'y' ,'z' ,'A' ,'B' ,'C' ,'D' ,'E' ,'F' ,'G' ,'H' ,'I' ,'J' ,'K' ,'L' ,'M' ,'N' ,'O' ,'P' ,'Q' ,'R' ,'S' ,'T' ,'U' ,'V' ,'W' ,'X' ,'Y' ,'Z' ,'0' ,'1' ,'2' ,'3' ,'4' ,'5' ,'6' ,'7' ,'8' ,'9' ,'!' ,'@' ,'#' ,'$' ,'%', '^', '&', '-', '_'};
@codeniko
codeniko / mousefix.c
Created August 19, 2014 01:55
Fix the wireless mouse if not responding.
#include <unistd.h>
#include <stdlib.h>
int main() {
setuid(0);
system("/sbin/modprobe -r hid_logitech_dj && /sbin/modprobe hid_logitech_dj");
}
@codeniko
codeniko / ircbotskel.c
Last active August 29, 2015 14:06
IRC Bot Skeleton
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <netdb.h>
int conn;
char sbuf[512];
void raw(char *fmt, ...) {
va_list ap;
@codeniko
codeniko / mvfiles.sh
Created December 26, 2014 04:08
Short script to move all non-dir files to a dir specified as the argument
#!/bin/bash
scriptname='mvfiles.sh'
if [ "$#" -ne 1 ]; then
/bin/echo "Pass in destination dir as argument"
exit 1
else
/bin/echo "$(/bin/ls -l | /bin/egrep '^-' | /usr/bin/tr -s ' ' | /usr/bin/cut -d ' ' -f 9-)" | while read line; do if [ "${line}" != "${scriptname}" ]; then /bin/mv "${line}" "${1}"; fi done
fi
<!doctype html>
<html>
<head>
<script src="//code.jquery.com/jquery-1.11.3.min.js"></script>
<script>
function getContent() {
http.get('content.php', function (res) {
var resChunks = '';
res.on('data', function (data) {
resChunks += data;
@codeniko
codeniko / transkill.sh
Created August 24, 2015 01:30
kill -9 transmission process
#!/bin/bash
kill -9 `ps -ef | grep trans | head -n 1 | xargs | cut -d ' ' -f 2`
@codeniko
codeniko / login.js
Last active July 26, 2017 21:32
login into yahoo and get cookies
var exec = require('child_process').exec;
var when = require('when');
function login(credentials) {
var whenAuthenticated = when.defer();
var user = credentials.user;
var pass = credentials.pass;
var res = {