Skip to content

Instantly share code, notes, and snippets.

View peterhil's full-sized avatar

Peter H. peterhil

View GitHub Profile
@ityonemo
ityonemo / test.md
Last active October 25, 2024 15:24
Zig in 30 minutes

A half-hour to learn Zig

This is inspired by https://fasterthanli.me/blog/2020/a-half-hour-to-learn-rust/

Basics

the command zig run my_code.zig will compile and immediately run your Zig program. Each of these cells contains a zig program that you can try to run (some of them contain compile-time errors that you can comment out to play with)

@joshnuss
joshnuss / httpStore.js
Last active October 11, 2023 11:29
A Svelte store backed by HTTP
import { writable } from 'svelte/store'
// returns a store with HTTP access functions for get, post, patch, delete
// anytime an HTTP request is made, the store is updated and all subscribers are notified.
export default function(initial) {
// create the underlying store
const store = writable(initial)
// define a request function that will do `fetch` and update store when request finishes
store.request = async (method, url, params=null) => {
@nivit
nivit / gist:3a7c15c656054b936c0dd16054b9b83a
Created May 25, 2020 15:48
Set up default browser in FreeBSD
* firefox
xdg-mime default firefox.desktop text/html
env BROWSER="" xdg-settings set default-web-browser firefox.desktop
env BROWSER="" xdg-settings set default-url-scheme-handler https firefox.desktop
env BROWSER="" xdg-settings set default-url-scheme-handler http firefox.desktop
* chrome (www/chromium)
xdg-mime default chromium-browser.desktop text/html
env BROWSER="" xdg-settings set default-web-browser chromium-browser.desktop
env BROWSER="" xdg-settings set default-url-scheme-handler https chromium-browser.desktop
@christoph-frick
christoph-frick / Awesome-Fennel.md
Last active October 9, 2024 12:58
Use fennel to write the awesome-wm config

How to write an awesome-wm config with Fennel

Awesome-WM is a X11 window manager, that is configured via Lua. Fennel is a Lisp for Lua. This shows a general setup of how to write your awesome-wm config using fennel directly without the compilation step (which would also work, but is not needed).

General setup

Fetch a recent Fennel version (the

@HendrixString
HendrixString / ansi.md
Last active September 23, 2024 18:02
ANSI 256 color codes resources
echo -e "testing \033[48;5;88mCOLOR1\033[38;208;48;5;159mCOLOR2\033[m"

The color range of a 256 color terminal consists of 4 parts, often 5, in which case you actually get 258 colors:

  • Color numbers 0 to 7 are the default terminal colors, the actual RGB value of which is not standardized and can often be configured.
  • Color numbers 8 to 15 are the "bright" colors. Most of the time these are a lighter shade of the color with index - 8. They are also not standardized and can often be configured. Depending on terminal and shell, they are often used instead of or in conjunction with bold font faces.
  • Color numbers 16 to 231 are RGB colors. These 216 colors are defined by 6 values on each of the three RGB axes. That is, instead of values 0 - 255, each color only ranges from 0 - 5.
@yakovsh
yakovsh / 2005_06_03-remove_vowels_from_hebrew.js
Last active May 23, 2022 19:43
Removing Vowels from Hebrew Unicode Text
/*
* One of the questions that recently came up is how to remove vowels from Hebrew characters in Unicode
* (or any other similar language). A quick look at Hebrew Unicode chart shows that the vowels are all
* located between 0x0591 (1425) and 0x05C7 (1479). With this and Javascript's charCodeAt function, it
* is trivial to strip them out with Javascript as follows
*
* Live demo is available here:
* https://jsfiddle.net/js0ge7gn/
*/
@gorangajic
gorangajic / es6-spread-immutable-cheatsheet.md
Last active April 11, 2024 08:32
es6 spread immutable cheatsheet

update object

var state = {
    id: 1,
    points: 100,
    name: "Goran"
};

var newState = {
@jeremyjbowers
jeremyjbowers / actions.py
Created November 24, 2015 21:47
Export to CSV for Django admin
import csv
from django.http import HttpResponse
def export_as_csv_action(description="Export selected objects as CSV file", fields=None, exclude=None, header=True):
"""
This function returns an export csv action
'fields' and 'exclude' work like in django ModelForm
'header' is whether or not to output the column names as the first row
"""
def export_as_csv(modeladmin, request, queryset):
@hal0gen
hal0gen / _mobile-ready-web-app.html
Last active November 10, 2024 12:00 — forked from tfausak/ios-8-web-app.html
iOS + Android settings for web applications
<!doctype html>
<!-- Adapted from https://gist.github.com/tfausak/2222823 -->
<html>
<head>
<title>Mobile-ready web app</title>
<!-- CONFIGURATION -->
@peterhil
peterhil / about.zsh
Created July 12, 2015 14:49
Grep man pages by sections
#!/usr/bin/env zsh
# -*- encoding: utf-8 -*-
# Copyright (c) 2015 by Peter Hillerström
# License: MIT License
# This can be sourced from zsh dotfiles. If you don't care about other
# functions than `about`, put them inside the about function.
# Output can be piped to GNU `fmt -s` command for nice formatting.
about() {