Skip to content

Instantly share code, notes, and snippets.

View adamallaf's full-sized avatar
👾

Adam Allaf adamallaf

👾
View GitHub Profile
@adamallaf
adamallaf / m_get_ip.py
Last active January 23, 2023 09:59
C get ip function equivalent in python3
import fcntl
import socket
import struct
"""
char *get_ip(char *iname) {
int fd;
struct ifreq ifr;
fd = socket(AF_INET, SOCK_DGRAM, 0);
@adamallaf
adamallaf / create_repo.sh
Last active January 23, 2023 22:30
Create git repository shell script for synology nas
#!/usr/bin/env sh
create_git_repository() {
if [ -z "$1" ]
then
echo "Usage: ./create_repo.sh NAME"
return
fi
cd /volume1/git/
git --bare init $1.git
@matthewearl
matthewearl / smblevextract.py
Last active February 21, 2025 03:24
Super Mario Bros Level Extractor
#!/usr/bin/env python3
#
# Copyright (c) 2018 Matthew Earl
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
@adamallaf
adamallaf / prog1.s
Last active January 3, 2018 02:41
Much Assembly Required manual control example
; Welcome to Much Assembly required!
; You will find useful information on the game here: https://github.com/simon987/Much-Assembly-Required/wiki
HWID_LEGS equ 0x0001
HWID_KEYBOARD equ 0x0004
HWID_DRILL equ 0x0005
HWID_HOLO equ 0x0009
HWID_BATTERY equ 0x000A
BATTERY_POLL equ 1
HOLO_DISP_HEX equ 1
@noelboss
noelboss / git-deployment.md
Last active August 12, 2025 18:16
Simple automated GIT Deployment using Hooks

Simple automated GIT Deployment using GIT Hooks

Here are the simple steps needed to create a deployment from your local GIT repository to a server based on this in-depth tutorial.

How it works

You are developing in a working-copy on your local machine, lets say on the master branch. Most of the time, people would push code to a remote server like github.com or gitlab.com and pull or export it to a production server. Or you use a service like deepl.io to act upon a Web-Hook that's triggered that service.

@hakre
hakre / iconv-l.txt
Created December 2, 2012 12:35
Iconv List of Encodings
ANSI_X3.4-1968 ANSI_X3.4-1986 ASCII CP367 IBM367 ISO-IR-6 ISO646-US ISO_646.IRV:1991 US US-ASCII CSASCII
UTF-8
ISO-10646-UCS-2 UCS-2 CSUNICODE
UCS-2BE UNICODE-1-1 UNICODEBIG CSUNICODE11
UCS-2LE UNICODELITTLE
ISO-10646-UCS-4 UCS-4 CSUCS4
UCS-4BE
UCS-4LE
UTF-16
UTF-16BE
@iartarisi
iartarisi / gist:4078879
Created November 15, 2012 14:28
mock open file
@contextmanager
def mock_open(filename, contents=None, complain=True):
"""Mock __builtin__.open() on a specific filename
Let execution pass through to __builtin__.open() on other
files. Return a BytesIO with :contents: if the file was matched. If
the :contents: parameter is not given or if it None, a BytesIO
instance simulating an empty file is returned.
If :complain: is True (default). Will raise an error if a
# build helloworld executable when user executes "make"
volumecontrol: volumecontrol.o
$(CC) $(LDFLAGS) -lasound volumecontrol.o -o volumecontrol
volumecontrol.o: volumecontrol.c
$(CC) $(CFLAGS) -c volumecontrol.c
# remove object files and executable when user executes "make clean"
clean:
rm *.o volumecontrol
@bradmontgomery
bradmontgomery / dummy-web-server.py
Last active September 24, 2025 10:25
a minimal http server in python. Responds to GET, HEAD, POST requests, but will fail on anything else.
#!/usr/bin/env python
"""
Very simple HTTP server in python (Updated for Python 3.7)
Usage:
./dummy-web-server.py -h
./dummy-web-server.py -l localhost -p 8000
Send a GET request:
@sixtenbe
sixtenbe / analytic_wfm.py
Last active August 30, 2025 04:16 — forked from endolith/peakdet.m
Peak detection in Python
#!/usr/bin/python2
# Copyright (C) 2016 Sixten Bergman
# License WTFPL
#
# This program is free software. It comes without any warranty, to the extent
# permitted by applicable law.
# You can redistribute it and/or modify it under the terms of the Do What The
# Fuck You Want To Public License, Version 2, as published by Sam Hocevar. See