Skip to content

Instantly share code, notes, and snippets.

@meskarune
meskarune / .tmux_prompt
Created April 6, 2015 18:08
include this fine in .tmux.conf with source ~/.tmux_prompt
set -g status-bg "colour236"
set -g message-command-fg "colour253"
set -g status-justify "left"
set -g status-left-length "100"
set -g status "on"
set -g pane-active-border-fg "colour109"
set -g message-bg "colour239"
set -g status-right-length "100"
set -g status-right-attr "none"
set -g message-fg "colour253"
@Earnestly
Earnestly / dealing_with_failed_install.rst
Last active October 17, 2016 18:49
Dealing with Installation Interruptions with Pacman

A Method to Correct Interrupted Installations with Pacman

An upgrade via pacman could be broken down into three phases:

1) Sync

Updates the sync databases with, if any, new packages. These are downloaded from the mirrors usually as gzip files located in /var/lib/pacman/sync such as core.db and extra.db.

@lpereira
lpereira / tpl-array.c
Created November 3, 2016 02:18
Lwan template with arrays
#include <lwan.h>
#include <lwan-template.h>
#include <strbuf.h>
struct thing {
lwan_tpl_list_generator_t generator;
const char *name;
};
#include <stdlib.h>
/*
* Defer an expression.
* This requires a block in an outer scope to have called defer_init,
* and the deferred statements will run once defer_run is called.
*/
#define defer(expr) \
do { \
__label__ _defer_label; \
@msafadieh
msafadieh / zoom-web-client-auto-redirect.user.js
Last active September 23, 2021 21:41
User script that redirects Zoom meeting links to the web client automatically
// ==UserScript==
// @name Zoom Web Client Auto Redirect
// @namespace https://zoom.us
// @version 0.1
// @description Automatically redirect Zoom meetings to the web client
// @author Mohamad Safadieh
// @license GNU AGPLv3: https://www.gnu.org/licenses/agpl-3.0.en.html
// @include /https:\/\/([a-z0-9\-]+\.)?zoom\.us\/([sj])\/([0-9]+).*/
// @grant none
// ==/UserScript==
@macournoyer
macournoyer / Output
Last active January 9, 2023 15:12
A Neural Network framework in 25 LOC
$ python xor.py
Training:
Epoch 0 MSE: 1.765
Epoch 100 MSE: 0.015
Epoch 200 MSE: 0.005
* Target MSE reached *
Evaluating:
1 XOR 0 = 1 ( 0.904) Error: 0.096
0 XOR 1 = 1 ( 0.908) Error: 0.092
1 XOR 1 = 0 (-0.008) Error: 0.008
@lpereira
lpereira / partial.c
Last active January 29, 2023 20:12
Partial functions in C This program illustrates a hack to create partial functions in C. The way it works is that it generates a template function (partial_template_function) with known pointers, that is later copied to a region of memory obtained with mmap(), patched up with the address and data to be passed to the real function, and then made …
/*
* Partial applied functions in C
* Leandro Pereira <leandro@tia.mat.br>
*/
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include <stdbool.h>
@vidavidorra
vidavidorra / auto-deploy_documentation.md
Last active February 19, 2023 17:37
Auto-deploying Doxygen documentation to gh-pages with Travis CI

Auto-deploying Doxygen documentation to gh-pages with Travis CI

This explains how to setup for GitHub projects which automatically generates Doxygen code documentation and publishes the documentation to the gh-pages branch using Travis CI. This way only the source files need to be pushed to GitHub and the gh-pages branch is automatically updated with the generated Doxygen documentation.

Sign up for Travis CI and add your project

Get an account at Travis CI. Turn on Travis for your repository in question, using the Travis control panel.

Create a clean gh-pages branch

To create a clean gh-pages branch, with no commit history, from the master branch enter the code below in the Git Shell. This will create a gh-pages branch with one file, the README.md in it. It doesn't really matter what file is uploaded in it since it will be overwritten when the automatically generated documentation is published to th

This document has moved!

It's now here, in The Programmer's Compendium. The content is the same as before, but being part of the compendium means that it's actively maintained.

@porglezomp
porglezomp / Leftpad.idr
Last active October 7, 2023 23:25
Taking on Hillel's challenge to formally verify leftpad (https://twitter.com/Hillelogram/status/987432181889994759)
import Data.Vect
-- `minus` is saturating subtraction, so this works like we want it to
eq_max : (n, k : Nat) -> maximum k n = plus (n `minus` k) k
eq_max n Z = rewrite minusZeroRight n in rewrite plusZeroRightNeutral n in Refl
eq_max Z (S _) = Refl
eq_max (S n) (S k) = rewrite sym $ plusSuccRightSucc (n `minus` k) k in rewrite eq_max n k in Refl
-- The type here says "the result is" padded to (maximum k n), and is padding plus the original
leftPad : (x : a) -> (n : Nat) -> (xs : Vect k a)