Skip to content

Instantly share code, notes, and snippets.

View yberreby's full-sized avatar

Yohaï-Eliel Berreby yberreby

View GitHub Profile
#include <stdint.h>
#include <immintrin.h>
#include <intrin.h>
#include <stdio.h>
// Count of set bits in `plus` minus count of set bits in `minus`
// The result is in [ -32 .. +32 ] interval
inline int popCntDiff( uint32_t plus, uint32_t minus )
{
plus = __popcnt( plus );
@nateraw
nateraw / stable_diffusion_walk.py
Created August 18, 2022 05:59
Walk between stable diffusion text prompts
"""
Built on top of this gist by @karpathy:
https://gist.github.com/karpathy/00103b0037c5aaea32fe1da1af553355
stable diffusion dreaming over text prompts
creates hypnotic moving videos by smoothly walking randomly through the sample space
example way to run this script:
$ python stable_diffusion_walk.py --prompts "['blueberry spaghetti', 'strawberry spaghetti']" --seeds 243,523 --name berry_good_spaghetti
@codelynx
codelynx / UnsafePointer Converter.swift
Created September 13, 2020 14:57
[swift] Unsafe Pointer conversion
//
// Swift UnsafePointer converter
// Kaz Yoshikawa
//
// These code demonstrates how to convert swift pointers to the other forms of pointers.
//
// Source:
// Swift の Array やら ArraySlice やらポインタの変換まとめ
// https://qiita.com/Satachito/items/4c39c9b06304e4d86660
//
@ChrisRackauckas
ChrisRackauckas / a_stiff_ode_performance_python_julia.md
Last active November 29, 2023 01:30
SciPy+Numba odeint vs Julia ODE vs NumbaLSODA: 50x performance difference on stiff ODE

SciPy+Numba odeint vs Julia DifferentialEquations.jl vs NumbaLSODA Summary

All are solved at reltol=1e-3, abstol=1e-6 using the fastest ODE solver of the respective package for the given problem.

Absolute Performance Numbers:

  • SciPy LSODA through odeint takes ~489μs
  • SciPy LSODA through odeint with Numba takes ~257μs
  • NumbaLSODA takes ~25μs
  • DifferentialEquations.jl Rosenbrock23 takes ~9.2μs
@chicobentojr
chicobentojr / _a-recipe-for-training-neural-networks.md
Created May 10, 2019 12:00
"A Recipe for Training Neural Networks" - Andrej Karpathy

A Recipe for Training Neural Networks - Andrej Karpathy

@DevonMorris
DevonMorris / i3URxvtCurrentDirectory.md
Last active October 7, 2022 12:32
i3 open URxvt in current directory, zsh

Add the following to a script in .config/i3/i3_shell.sh

#!/usr/bin/env bash
WHEREAMI=$(cat /tmp/whereami)
i3-sensible-terminal -cd $WHEREAMI

To call store the environment variable WHEREAMI put

@shafik
shafik / WhatIsStrictAliasingAndWhyDoWeCare.md
Last active May 8, 2024 17:59
What is Strict Aliasing and Why do we Care?

What is the Strict Aliasing Rule and Why do we care?

(OR Type Punning, Undefined Behavior and Alignment, Oh My!)

What is strict aliasing? First we will describe what is aliasing and then we can learn what being strict about it means.

In C and C++ aliasing has to do with what expression types we are allowed to access stored values through. In both C and C++ the standard specifies which expression types are allowed to alias which types. The compiler and optimizer are allowed to assume we follow the aliasing rules strictly, hence the term strict aliasing rule. If we attempt to access a value using a type not allowed it is classified as undefined behavior(UB). Once we have undefined behavior all bets are off, the results of our program are no longer reliable.

Unfortunately with strict aliasing violations, we will often obtain the results we expect, leaving the possibility the a future version of a compiler with a new optimization will break code we th

#!/bin/bash
################################
# OS X Install ISO Creater #
# #
# Author: shela #
################################
#######################################
# Declarations
@vszakats
vszakats / codesign.sh
Last active May 9, 2024 10:23
Code-signing PE executables using OpenSSL, osslsigncode (and more)
#!/bin/sh
# To the extent possible under law, Viktor Szakats
# has waived all copyright and related or neighboring rights to this
# script.
# CC0 - https://creativecommons.org/publicdomain/zero/1.0/
# SPDX-License-Identifier: CC0-1.0
# shellcheck disable=SC3040,SC2039
set -o errexit -o nounset; [ -n "${BASH:-}${ZSH_NAME:-}" ] && set -o pipefail
@Property404
Property404 / beer.c
Last active December 3, 2023 06:18
Obfuscated 99 Bottles of Beer (compile with gcc -w --trigraphs beer.c). No semicolons, curly brackets, declarations of variable types, or numeric literals
// Are you there god??/
??=define _(please, help)
??=define _____(i,m, v,e,r,y) r%:%:m
??=define ____ _____(a,f,r,a,i,d)
main(__)<%____(!_(-~-??-((-~-??-!__<<-
??-!!__)<<-??-(!!__<<!!__))+-~-~-??--~-~
-~-~-~-~-??-(-~-~-~-~-??-!!__<<-~!!__),-
??-!__))<%??>%>_(__,___)??<____
(printf("please let me die??/r%d bottle%s"
" of bee%s""""??/n",(!(___