Skip to content

Instantly share code, notes, and snippets.

View Jacajack's full-sized avatar
🦄

Jacek Wieczorek Jacajack

🦄
View GitHub Profile
@Jacajack
Jacajack / chbp.py
Created February 28, 2016 17:16
Python dictionary password generator (like correct horse battery staple)
#!/usr/bin/python
import random;
import sys;
Words = [Word.rstrip( '\n' ) for Word in open( "/usr/share/dict/american-english") ];
Length = raw_input( "How many words should Your xkcd like password have? " );
try:
@Jacajack
Jacajack / mcscan.py
Created March 5, 2016 15:30
Scanner for Minecraft servers - when server is down, run it to get notified when it's up again
#!/usr/bin/python3
import subprocess;
import time;
import os;
import sys;
try:
Address = sys.argv[1];
except:
Address = input( "Give me server IP: " );
@Jacajack
Jacajack / pi.c
Last active May 25, 2016 13:32
Simple code that calculates and looks like Pi...
#include <stdio.h>
#include <inttypes.h>
int main(){uintmax_t step=0;
long double pi=4.0L;while(1)
{pi+= 4.0/ (
3.0L+ step *
2.0L) *( (
step% 2==0 )
?-1:1 );step
@Jacajack
Jacajack / debug.h
Last active May 29, 2016 22:08
Simple C debugging macro
#include <stdio.h>
#ifndef _DEBUG_HEADER
#define _DEBUG_HEADER
#ifndef DEBUG_ENABLED
#define DEBUG_ENABLED 0
#endif
#ifndef DEBUG_OUT
@Jacajack
Jacajack / pimonte.c
Created May 25, 2016 14:20
Simple code calculating Pi with Monte Carlo method (this time in shape of square)
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#define SQ(x) ((x)*(x))
#define DIA 200.0L
int main( ){uintmax_t step = 0,
cir= 0; double x, y;long double
pi; while ( 1 ) { x = ( double)
rand()/RAND_MAX*DIA- DIA / 2.0;
@Jacajack
Jacajack / byzanz-record-region.sh
Created May 26, 2016 20:17
Record screen region with Byzanz and xrectsel
#!/bin/bash
#Records selected screen region, with GUI
#This is combined version of GIF recording scripts, that can be found here: http://askubuntu.com/questions/107726/how-to-create-animated-gif-images-of-a-screencast
#Thanks to Rob W, and the other author (unmentioned), for creating this lovely scripts
#I do not own any rights to code I didn't write
# ~Jacajack
@Jacajack
Jacajack / uartm8.c
Last active July 17, 2016 22:26
UART snippet for ATmega 8
#include <avr/io.h>
#include <stdlib.h>
#include "../include/uart.h"
//Version for atmega8
//Not used by default, just declared for user
char *uartBuffer;
void uartSendChar( char c )
@Jacajack
Jacajack / uartm328.c
Last active July 20, 2016 00:11
UART snippet for ATmega328
#include <avr/io.h>
#include <stdlib.h>
#include <util/delay.h>
#include "../include/uart.h"
//Version for atmega328
//Not used, just declared for user
char *uartBuffer;
static unsigned int uartBaud;
@Jacajack
Jacajack / eeprom.c
Created July 20, 2016 00:12
EEPROM snippet for AVR
#include <avr/io.h>
#include "../include/eeprom.h"
void eepromWrite( unsigned int address, unsigned char data )
{
//Wait for EEPROM to be ready
while ( EECR & ( 1 << EEPE ) );
EEAR = address;
EEDR = data;
@Jacajack
Jacajack / displist.awk
Last active August 19, 2016 02:29
Display formatted product list, and manage prices
#!/usr/bin/awk -f
#Sample list
#Milk <(2)[1][2.00]>
#Butter <(10)[2][1.00]>
#Basic init
BEGIN {
total = 0;
tokencnt = 0;