Skip to content

Instantly share code, notes, and snippets.

View mikroskeem's full-sized avatar
👻

Mark Vainomaa mikroskeem

👻
View GitHub Profile
@mikroskeem
mikroskeem / date_net.py
Created January 18, 2015 14:24
Uses i2clcd library and shows Date/time and network on 16x2 LCD
import i2clcd
import time, datetime, subprocess, re
lcd = i2clcd.lcd(0x38,1)
matcher = re.compile("0% packet loss")
while True:
date = datetime.datetime.now().strftime("%H:%M:%S")
ping = subprocess.Popen(["ping", "-c", "1", "neti.ee"],stdout = subprocess.PIPE,stderr = subprocess.PIPE)
out, error = ping.communicate()
lcd.lcd_clear()
lcd.lcd_puts("Time: {}".format(date), 1);
#include <sys/mount.h>
int r;
const char *targ = "/mnt";
const char *src = "/home/mark/lx/m.squash";
const char *fs = "squashfs";
unsigned long mflags;
const void *data;
int main(){
r = mount(src,targ,fs,mflags,data);
@mikroskeem
mikroskeem / nanoshell.c
Created February 6, 2015 19:38
nanoshell
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>
void parseargv(char *l, char **a){
while(*l != '\0') {
while (*l == ' ' || *l == '\t' || *l == '\n')
@mikroskeem
mikroskeem / index.php
Last active August 29, 2015 14:15
Led blinker made in Raspberry Pi cluster building @ Tartu
<html>
<meta charset="utf-8">
<body>
<h1>Led test</h1>
<button onClick="b()"><span id="lol"></span></button>
<script>
var is_running="<?php
if($_GET["run"] == "1"){
shell_exec("/home/pi/suid -c '/home/pi/vilguta.sh' >/dev/null"); echo "1";
} else if($_GET["run"] == "0"){
@mikroskeem
mikroskeem / fortune.desktop
Created March 11, 2015 12:38
Displays fortune on login
[Desktop Entry]
Type=Application
Name=Fortune notification
Comment=Fortune in notification
Exec=/home/mark/bin/fortune.py
OnlyShowIn=GNOME;
X-GNOME-Autostart-Phase=Application
@mikroskeem
mikroskeem / server.c
Created March 28, 2015 11:36
stdio to unix socket
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <unistd.h>
#define SOCK_PATH "echo_socket"
@mikroskeem
mikroskeem / 0x0.sh
Last active November 3, 2024 12:29
Arch Linux must-have packages
#!/usr/bin/env bash
0x0() {
case "${1}" in
"s")
shift
local url=`curl --silent -F"shorten=${1}" https://0x0.st | sed 's/\n//'`
echo -n "${url}"
;;
"u")
@mikroskeem
mikroskeem / login.py
Created April 11, 2015 10:26
Does same thing as /bin/login, just without permission weirdness like systemd-logind does
#!/usr/bin/env python3
#Deps: https://github.com/leonnnn/python3-simplepam
from simplepam import authenticate
import getpass
import os
import time
import sys
import socket
hostname = socket.gethostname()
x = 0
@mikroskeem
mikroskeem / vimrc.vim
Last active February 7, 2016 22:34
Tiny (neo)vim config
" ###### Many settings, wow'
" Better tab completion
set wildmode=longest,list,full
" Airline does this already
set noshowmode
" Do not use double space on some characters
set ambiwidth=single
" Remove startup screen
set shortmess+=I
@mikroskeem
mikroskeem / uniqify.py
Created June 13, 2015 21:45
removes duplicates from array
# http://www.peterbe.com/plog/uniqifiers-benchmark
def uniqify(seq, idfun=None):
# order preserving
if idfun is None:
def idfun(x): return x
seen = {}
result = []
for item in seq:
marker = idfun(item)