Skip to content

Instantly share code, notes, and snippets.

@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 / 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
@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
[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 / 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 / gist:7781397
Last active December 30, 2015 05:18
Zenit 3 987654327 2 5 vypocita zvysok velkeho exponencialneho cisla. - http://stackoverflow.com/questions/5989429/pow-and-mod-function-optimization
uint64_t expmod(uint64_t base, uint64_t exp, uint64_t mod ){
if (exp == 0) return 1;
return (exp % 2 == 0) ? ( ((uint64_t) pow( expmod( base, (exp / 2), mod), 2) ) % mod ) : ((base * expmod( base, (exp - 1), mod)) % mod);
}
online 2.525 ms
@mochja
mochja / function.less
Last active December 20, 2015 23:49
Split images, make opacity version, LESS function. (all icons are in simple png file along with hover versions)
@img-count: 4; // you need keep count of your images
@icon-width: 40px;
.image-icon (@pos: 0) when (@pos = 1) {
background-position-y: 0;
&:hover, &.active {
background-position-y: (@icon-width * -@img-count);
}
}