Skip to content

Instantly share code, notes, and snippets.

View FSX's full-sized avatar
💭
I may be slow to respond.

Frank FSX

💭
I may be slow to respond.
View GitHub Profile
@Jonarod
Jonarod / README.md
Last active April 20, 2024 19:27
Install Alpine Linux on Hetzner cloud
  1. Create an hetzner server using Ubuntu
  2. Go to the Hetzner's Server dashboard > Images
  3. Click on "Mount" over the alpine-linux-extended.iso image
  4. Shutdown the server
  5. Start the server
  6. Click the "Console" icon from the dashboard to open an interactive terminal session
  7. Login is root
  8. Configure the interface using the command setup-interfaces
  9. Pick to setup default eth0
  10. Custom config: no
@fsbs
fsbs / pycurl_multi_socket_action.py
Created September 16, 2019 15:13
Example of driving transfers with pycurl's multi.socket_action
import asyncio
import pycurl
import selectors
MULTI = pycurl.CurlMulti()
SELECTOR = selectors.DefaultSelector()
LOOP = asyncio.get_event_loop()
TIMER = None
@munificent
munificent / generate.c
Last active March 18, 2024 08:31
A random dungeon generator that fits on a business card
#include <time.h> // Robert Nystrom
#include <stdio.h> // @munificentbob
#include <stdlib.h> // for Ginny
#define r return // 2008-2019
#define l(a, b, c, d) for (i y=a;y\
<b; y++) for (int x = c; x < d; x++)
typedef int i;const i H=40;const i W
=80;i m[40][80];i g(i x){r rand()%x;
}void cave(i s){i w=g(10)+5;i h=g(6)
+3;i t=g(W-w-2)+1;i u=g(H-h-2)+1;l(u
@alirobe
alirobe / reclaimWindows10.ps1
Last active April 26, 2024 17:59
This Windows 10 Setup Script turns off a bunch of unnecessary Windows 10 telemetery, bloatware, & privacy things. Not guaranteed to catch everything. Review and tweak before running. Reboot after running. Scripts for reversing are included and commented. Fork of https://github.com/Disassembler0/Win10-Initial-Setup-Script (different defaults). N.…
###
###
### UPDATE: For Win 11, I recommend using this tool in place of this script:
### https://christitus.com/windows-tool/
### https://github.com/ChrisTitusTech/winutil
### https://www.youtube.com/watch?v=6UQZ5oQg8XA
### iwr -useb https://christitus.com/win | iex
###
###
from sre_parse import Pattern, SubPattern, parse as sre_parse
from sre_compile import compile as sre_compile
from sre_constants import BRANCH, SUBPATTERN
class Scanner(object):
def __init__(self, tokens, flags=0):
subpatterns = []
pat = Pattern()

Problems & Solutions for Interaction Between C and Go

At Vimeo, on the transcoding team, we work a lot with Go, and a lot with C, for various tasks such as media ingest. This means we use CGO quite extensively, and consequently, have run into bits that are perhaps not very well documented, if at all. Below is my effort to document some of the problems we've run into, and how we fixed or worked around them.

Many of these are obviously wrong in retrospect, but hindsight is 20/20, and these problems do exist in many codebases currently.

Some are definitely ugly, and I much welcome better solutions! Tweet me at @daemon404 if you have any, or have your own CGO story/tips, please! I'd love to learn of them.

Table of Contents

@barosl
barosl / add.c
Created July 26, 2015 07:26
Function overloading in C
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int addi(int a, int b) {
return a + b;
}
char *adds(char *a, char *b) {
char *res = malloc(strlen(a) + strlen(b) + 1);
from ijson import common
from ijson.backends import YAJLImportError
from cffi import FFI
ffi = FFI()
ffi.cdef("""
typedef void * (*yajl_malloc_func)(void *ctx, size_t sz);
typedef void (*yajl_free_func)(void *ctx, void * ptr);
typedef void * (*yajl_realloc_func)(void *ctx, void * ptr, size_t sz);
@olov
olov / gist:eb60ab878eb73a7c5e22
Created October 15, 2014 08:55
listenandservetls_nossl30.go
// You don't want to serve HTTPS supporting for SSL3.0 any longer, see:
// http://googleonlinesecurity.blogspot.de/2014/10/this-poodle-bites-exploiting-ssl-30.html
import (
"crypto/tls"
"net/http"
)
// This code supports SSL3.0, TLS1.0, TLS1.1 and TLS1.2
// Chances are you currently do this but want to stop due to the POODLE
err := http.ListenAndServeTLS(addr, "crtfile", "keyfile", handler)
@jeanbza
jeanbza / automate_2048.md
Last active July 9, 2023 03:42
Automate 2048

So I got to playing 2048 a decent amount, and starting getting the feeling that there was a 'pattern' that would win this game for me. Perhaps you've had the same thought! As a result, I wrote a little snippet of code that that cycles throw the keys Up, Right, Down, Left (feel free to create your own pattern).

Copy and paste this into your Chrome/Firefox console to automate 2048!

Firefox

function pressKey(i) {
  var evt = document.createEvent("KeyboardEvent");
  evt.initKeyEvent ("keydown", true, true, window, 0, 0, 0, 0, 37+i%4, 37+i%4);
 document.dispatchEvent(evt);