Skip to content

Instantly share code, notes, and snippets.

@mochja
mochja / A.md
Last active July 27, 2023 14:25
Sync your random scripts to gist

sync-gist

I write scripts everyday, and it's hard to keep them sorted. I wrote this simple tool that allows me to sync them to gist whenever I want. This is nice because I can write script in random places and make sure I never loose it.

For now this only works one-way - me pushing to gist.

Usage

sync-gist -f my-script
[Unit]
Description=Update nginx config on docker container restart
After=docker.service
[Service]
Type=simple
ExecStart=/root/dokku-update-nginx-on-container-restart.sh
Restart=on-failure
RestartSec=5s

Keybase proof

I hereby claim:

  • I am mochja on github.
  • I am mochja (https://keybase.io/mochja) on keybase.
  • I have a public key ASDpCwFxm3RuAIXdPg-vajiDKCq-boeMPcIxa_6N6UsyiQo

To claim this, I am signing this object:

#!/bin/bash
timestamp=`date +%Y%m%d-%H%I%S`
name="artifacts-$timestamp.zip"
channels="#dev"
url="https://slack.com/api/files.upload"
zip -r "$name" . || exit 0
curl -F file=@"$name" \
@mochja
mochja / main.c
Last active September 25, 2023 15:08
Yoga + OpenGL Example
#include <GLFW/glfw3.h>
#include <yoga/Yoga.h>
#include <stdlib.h>
int main(void)
{
GLFWwindow* window;
/* Initialize the library */
if (!glfwInit())
@mochja
mochja / sinon2-stub-callsFake-transform.js
Created April 5, 2017 12:46
Sinon2 jscodeshift transformer for 3 args stub calls
const _ = require('lodash');
module.exports = function(fileInfo, api) {
const j = api.jscodeshift;
const root = j(fileInfo.source);
root.find(j.CallExpression, {
callee: {
type: 'MemberExpression',
@mochja
mochja / spread.sh
Created March 3, 2016 11:48
Spread changes to last file modification
#!/bin/bash
for f in $(git status --porcelain); do
if [ -f "$f" ]; then
hash=$(git log -n1 --pretty=%H "$f")
if [ ! -z "$hash" ]; then
git add "$f" && git commit --fixup "$hash"
fi;
fi
done
@mochja
mochja / README.md
Last active December 16, 2015 09:09
VM IFJ15

VM

Na zaciatku sa premapuju skakajuce instrukcie na realne adresy targetujucej instrukcie, odstrania sa tym padom label instrukcie.

CALL MAIN
EXIT
LABEL MAIN
ADD 3 2
@mochja
mochja / gist:eac408065eb34ee1793c
Last active December 4, 2015 18:24
Instruction generator
INSTR_T create_{{ iname }}_{{ ptype }}_instr(const int a, const int b) {
instruction_t *i = calloc(1, sizeof(instruction_t));
i->type = I_{{ iname }};
ZVAL_INIT_INT(i->first, a);
ZVAL_INIT_INT(i->second, b);
return i;
}
@mochja
mochja / gist:40d2eedaba55ce99149f
Created November 29, 2015 06:12
mk only efi iso
xorriso -as mkisofs -R -f \
-full-iso9660-filenames \
-e EFI/BOOT/efiboot.img \
-no-emul-boot \
-output "./efi.iso" "/tmp/ram/efi"