Skip to content

Instantly share code, notes, and snippets.

@sbz
sbz / lcap.c
Last active January 26, 2024 14:33
example of using linux capabilities interface libcap(3) and dump capabilities flags for the running process
#include <sys/capability.h>
#include <sys/types.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#define nitems(x) (sizeof(x) / sizeof(x[0]))
int
main(void) {
@glisha
glisha / arduino_ds18b20.c
Created June 30, 2012 18:10
Хаклаб температурни сензори (https://cosm.com/feeds/64655)
#include <OneWire.h>
#include <LiquidCrystal.h>
// For every sensor found it outputs to serial:
// SensorID,CurrentTemp,Readout time,Current time
// Info at: http://wiki.spodeli.org/Хаклаб/Температура
OneWire ds(12); // on pin 12
LiquidCrystal lcd(6, 7, 8, 9, 10, 11);
@gdamjan
gdamjan / pxe-vm.sh
Last active June 14, 2023 01:53
A script to start a qemu-kvm virtual machine that boots from PXE (it'll configure a bridge and add eth0 to it)
#!/bin/bash
MEM=1024
LAN=eth0
BRIDGE=virtbr
ARCH=x86_64 # i386
#BIOS="-bios OVMF.fd" # to emulate an UEFI netboot
# supported wifi interfaces can be bridged if you set 4addr mode first:
# iw dev $LAN set 4addr on
@stephenturner
stephenturner / ismb_twitter.R
Created July 17, 2012 22:35
Plot twitter hashtag usage over time and 40 most prolific authors
library(twitteR)
library(ggplot2)
tweets <- list()
dates <- paste("2012-07-",11:18,sep="") # need to go to 18th to catch tweets from 17th
for (i in 2:length(dates)) {
print(paste(dates[i-1], dates[i]))
tweets <- c(tweets, searchTwitter("#ISMB", since=dates[i-1], until=dates[i], n=1500))
}
@rgreenjr
rgreenjr / postgres_queries_and_commands.sql
Last active July 5, 2024 04:29
Useful PostgreSQL Queries and Commands
-- show running queries (pre 9.2)
SELECT procpid, age(clock_timestamp(), query_start), usename, current_query
FROM pg_stat_activity
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- show running queries (9.2)
SELECT pid, age(clock_timestamp(), query_start), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'
@spion
spion / food.md
Last active October 13, 2015 20:37
Diet basics

This article contains some basic condensed knowledge about food.

Basic metabolism mechanics

Water

Water - your metabolism needs it. Have a full hand-held bottle nearby at all times. Drink liberally - most estimates of recommended amount fall between 3-5 liters per day (a lot more than what you will usually drink).

Infact, forget all other drinks, especially soft drinks and artificial juices. Most of them are sugary and will become fat minutes after you drink them. Replace them all with water.

@spion
spion / node-async-bfs.js
Created February 11, 2013 19:11
node async generic breadth first search
var async = require('async');
exports.bfs = function bfs(start, moves, goal, done) {
goal(start, function(err, res) {
if (res) done(null, [start]);
else explore([start], 1);
});
var depth = 0;
var foundGoal = null;
var visited = {};

Where people struggle learning Django

Over the last 3 years or so I've helped a bunch of companies, small and large, switch to Django. As part of that, I've done a lot of teaching Django (and Python) to people new to the platform (and language). I'd estimate I've trained something around 200-250 people so far. These aren't people new to programming — indeed, almost all of them are were currently employed as software developers — but they were new to Python, or to Django, or to web development, or all three.

In doing so, I've observed some patterns about what works and what doesn't. Many (most) of the failings have been my own pedagogical failings, but as I've honed my coursework and my skill I'm seeing, time and again, certain ways that Django makes itself difficult to certain groups of users.

This document is my attempt at organizing some notes around what ways different groups struggle. It's not particularly actionable — I'm not making any arguments about what Django should or shouldn't do (at least

@willurd
willurd / web-servers.md
Last active July 5, 2024 18:32
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000

Understanding this in JavaScript

It's easy to trip up on the meaning of this in JavaScript. The behavior is very different from other languages, which means we have to throw most preconceptions and intuition out the window.

The best way to think of this in JS is as a hidden function argument which is passed in a slightly awkward way. Instead of the normal passing of arguments:

fn(arg1, arg2, arg3)