Skip to content

Instantly share code, notes, and snippets.

View MrYakobo's full-sized avatar
Not AI

Jakob Lindskog MrYakobo

Not AI
View GitHub Profile
@MrYakobo
MrYakobo / printf ARM
Last active May 13, 2022 11:26
print number to stdout in Raspberry Pi ARM Assembly
(this file changes the title of this Gist, ignore this)
@MrYakobo
MrYakobo / factorial.s
Last active May 22, 2017 09:23
factorial in ARM assembly
;R0 parameter
factorial
PUSH {R1, R2, LR}
CMP R0, #1
BEQ ret ; return 1
MOV R1, R0 ; kopiera R0 till R1
SUB R0, R0, #1 ; dec R0
BL factorial ; anropa factorial
MUL R2, R1, R0 ; int result = fact(n-1)*n
MOV R0, R2 ; R0 = result
@MrYakobo
MrYakobo / exempel.js
Created June 29, 2017 22:27
Namnsdagar för hela året i en JSON-array.
//just i javascript är det lite småjobbigt att få fram ett index för nuvarande dag på året... suck
//https://stackoverflow.com/questions/8619879/javascript-calculate-the-day-of-the-year-1-366
Date.prototype.isLeapYear = function() {
var year = this.getFullYear();
if((year & 3) != 0) return false;
return ((year % 100) != 0 || (year % 400) == 0);
};
// Get Day of Year
Date.prototype.getDOY = function() {
@MrYakobo
MrYakobo / example.png
Last active November 29, 2017 20:09
DNS setup for custom domain on Github
example.png
var a = $("a>img").map((i,t)=>$(t).attr('data-src'));
var arr = [];
for(var i = 0; i < a.length; i++)
arr.push(a[i]);
var c = arr.map(t=>{
var b = `-o ${/[^\/]+?\.png|[^\/]+?\.jpg/.exec(t)}`
if(b != null){
@MrYakobo
MrYakobo / update-code
Created February 23, 2018 13:11
If your distro doesn't pack VSCode and you want to update it.
#!/bin/bash
curl -L https://vscode-update.azurewebsites.net/latest/linux-x64/stable | tar xz -C ~/Downloads/vscode/
# symlink ~/bin/code to ~/Downloads/vscode
ln -s ~/Downloads/vscode ~/bin/code
@MrYakobo
MrYakobo / dl.sh
Last active August 30, 2018 15:24
Automated download and extract process from https://wiiu.hacks.guide/get-started
#!/usr/bin/env bash
echo "This script follows the guide from https://wiiu.hacks.guide/get-started as of 2018-08-30."
mkdir -p SDCARD
cd SDCARD
declare -a files=(
https://wiiu.hacks.guide/assets/files/config.txt \
https://wiiu.hacks.guide/assets/files/config.ini \
https://github.com/vgmoose/hbas/releases/download/1.5/appstore15.zip \
@MrYakobo
MrYakobo / bspwmrc
Created September 3, 2018 18:50
Unixporn configs
#! /bin/sh
bspc config border_width 0
bspc config window_gap 12
bspc config split_ratio 0.60
bspc config borderless_monocle true
bspc config gapless_monocle true
bspc config single_monocle true
bspc config focus_by_distance true
bspc config adaptive_raise true
@MrYakobo
MrYakobo / paging.py
Last active July 7, 2020 16:22
Google-like pagination algorithm
#!/usr/bin/env python3
# heavily inspired by https://jasonwatmore.com/post/2016/01/31/angularjs-pagination-example-with-logic-like-google
import math
def paginate(curr, itemsPerPage, numItems, numPagesToShowAtOnce):
# ceil here to make sure we don't miss anything
half = math.ceil(numPagesToShowAtOnce / 2)
numPages = math.ceil(numItems / itemsPerPage)
@MrYakobo
MrYakobo / info.md
Created August 24, 2020 17:40
List of all shortcodes in Visual Composer

these are from js_composer

Anyhow, this comphrenhensive list was ungooglable for me. Googling "List of Visual Composer Shortcodes" gives nothing at all. I guess that's how it goes with most of Wordpress things; references are sparse and examples are numerous. Reminds me of Classic ASP, where W3Schools literally is your best reference. Because Microsoft don't document shit.

Anyhow, hope this is useful to someone