Skip to content

Instantly share code, notes, and snippets.

View TheSirC's full-sized avatar
💭
Chopping some HEADs down

le Duc Banal TheSirC

💭
Chopping some HEADs down
View GitHub Profile
@bellbind
bellbind / genetic.py
Created December 15, 2010 10:46
[python]Genetic Algorithm example
"""Genetic Algorithmn Implementation
see:
http://www.obitko.com/tutorials/genetic-algorithms/ga-basic-description.php
"""
import random
class GeneticAlgorithm(object):
def __init__(self, genetics):
self.genetics = genetics
pass
@hellerbarde
hellerbarde / latency.markdown
Created May 31, 2012 13:16 — forked from jboner/latency.txt
Latency numbers every programmer should know

Latency numbers every programmer should know

L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns
L2 cache reference ........................... 7 ns
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns             
Compress 1K bytes with Zippy ............. 3,000 ns  =   3 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns  =  20 µs
SSD random read ........................ 150,000 ns  = 150 µs

Read 1 MB sequentially from memory ..... 250,000 ns = 250 µs

@jareware
jareware / SCSS.md
Last active July 1, 2024 09:25
Advanced SCSS, or, 16 cool things you may not have known your stylesheets could do

⇐ back to the gist-blog at jrw.fi

Advanced SCSS

Or, 16 cool things you may not have known your stylesheets could do. I'd rather have kept it to a nice round number like 10, but they just kept coming. Sorry.

I've been using SCSS/SASS for most of my styling work since 2009, and I'm a huge fan of Compass (by the great @chriseppstein). It really helped many of us through the darkest cross-browser crap. Even though browsers are increasingly playing nice with CSS, another problem has become very topical: managing the complexity in stylesheets as our in-browser apps get larger and larger. SCSS is an indispensable tool for dealing with this.

This isn't an introduction to the language by a long shot; many things probably won't make sense unless you have some SCSS under your belt already. That said, if you're not yet comfy with the basics, check out the aweso

@willemo
willemo / passwordless-ssh.md
Last active November 22, 2022 12:46
Passwordless SSH/SFTP access to a server

Passwordless SSH/SFTP for dummies

To get SSH or SFTP access to a server without using a password you need to have a SSH key pair for each computer you want to be able to access the server from. In this document I’ll describe the steps you need to take to generate a key pair if you don’t have one already. If you do, you can use your public key(s) to get access to the server.

I'll also explain how to connect to your server using Cyberduck. Click here to skip to that part.

Disclaimer and stuff

This guide is written with newbies in mind, so I'm very thorough in describing the steps that you must take. This guide will not cover setting up the server side of this system. It assumes that there's a server running with SSH enabled.

@charudatta10
charudatta10 / genetic.py
Last active September 9, 2017 15:38 — forked from bellbind/genetic.py
"""Genetic Algorithmn Implementation
see:
http://www.obitko.com/tutorials/genetic-algorithms/ga-basic-description.php
"""
import random
class GeneticAlgorithm(object):
def __init__(self, genetics):
self.genetics = genetics
pass
@passuf
passuf / .xprofile
Last active April 2, 2023 09:13 — forked from zoqaeski/custom
Remap Logitech R400 Presenter Keys
# Add these commands to your ~/.xprofile file
/usr/local/bin/map_logitech_r400_keys_exec &
/usr/local/bin/file-inotify /tmp/logitech-r400.lock /usr/local/bin/map_logitech_r400_keys_exec &
@revov
revov / README.md
Last active April 2, 2023 09:13
Remapping keys on Linux for a specific device (Wireless Laser Presenter)

Recently I bought a Chinese Wireless Laser Presenter. I planned on using it for RevealJS presentations and it worked perfectly (as PageUP/PageDown traverse well in the 2D slides). However, in order to have more control I wanted to map the other two buttons (FullScreen, BlankScreen) to Up and Down arrows, as well as remapping the PgUp/PgDn buttons to Left and Right. Since I will most probably be using Linux when giving presentations I though it would be easy to remap them. I quickly realised how wrong I was.

The presenter worked on Wayland but remapping the keys would be mission impossible. xinput --list didn't detect the presenter (the only way to get its EventID was to use the lower level sudo libinput-list-devices). The next steps that I am going to present also caused errors, so Wayland is out of the question as I didn't have patience to dig through it.

As I was skimming through various StackOverflow threads and blog posts I gained a bit of knowledge on how the Linux systems work with regards to inpu

@Softsapiens
Softsapiens / builder.sh
Created July 27, 2018 09:17 — forked from jefdaj/builder.sh
Draft nix expression to wrap debian packages.
source $stdenv/setup
PATH=$dpkg/bin:$PATH
dpkg -x $src unpacked
cp -r unpacked/* $out/
@mbbx6spp
mbbx6spp / .00readme.org
Last active May 26, 2024 22:53
A caching and persistent Nix shell with direnv

Cached and Persistent Nix shell with direnv integration

Problem being solved

  • the default direnv Nix integration from projects loads a Nix shell every new terminal or every time shell.nix and/or default.nix changes. On larger projects with a lot of Nix shell dependencies, that can cause the terminal to take more than 6 seconds to load, which significantly degrades the developer experience (DX).
  • when a developer garbage collects in their Nix store, often the Nix shell dependencies are deleted also which causes a slow start the next time the project’s Nix shell is requested, also degrading developer experience (DX).

Solution outline

  • on first Nix shell load, the Nix shell is evaluated fully such that direnv dumps the environment from the spawn Nix shell process
@elvetemedve
elvetemedve / 85-yubikey.rules
Created October 28, 2018 19:59
Lock/unlock user session on Linux with Yubikey
# Yubikey Udev Rule: running a bash script in case your Yubikey is inserted/removed
ACTION=="add", ENV{PRODUCT}=="1050/407/511", ENV{DEVTYPE}=="usb_device", RUN+="/usr/local/bin/pam-session-locker.sh unlock"
ACTION=="remove", ENV{PRODUCT}=="1050/407/511", ENV{DEVTYPE}=="usb_device", RUN+="/usr/local/bin/pam-session-locker.sh lock"