Skip to content

Instantly share code, notes, and snippets.

View dyladan's full-sized avatar

Daniel Dyla dyladan

View GitHub Profile
@dyladan
dyladan / app.js
Last active May 14, 2020 17:29 — forked from luebken/app.js
const { PrometheusExporter } = require('@opentelemetry/exporter-prometheus');
const { MeterProvider } = require('@opentelemetry/metrics');
const { Resource } = require('@opentelemetry/resources');
// Add your port and startServer to the Prometheus options
const options = {port: 9464, startServer: true};
const exporter = new PrometheusExporter(options);
@dyladan
dyladan / asynchronous_explainer.js
Last active July 1, 2019 16:47
This is an example of all the ways asynchronous operations may be carried out in javascript
/*
* First, we will declare some asynchronous functions to consume.
* These actually do not make asynchronous calls, but they illustrate
* the idea.
*/
// Callback style asynchronous function
function callbackAsyncFunction(val1, val2, callback) {
//processing
if (!val1) {

Keybase proof

I hereby claim:

  • I am dyladan on github.
  • I am dyladan (https://keybase.io/dyladan) on keybase.
  • I have a public key ASCQJRskHagulIcF37NVYMsR_g_rZpBY3PmbSEtbbtFvSgo

To claim this, I am signing this object:

import csv, sqlite3
con = sqlite3.connect("logstats.sqlite")
cur = con.cursor()
cur.execute("""\
CREATE TABLE messages (
time DATETIME NOT NULL,
server VARCHAR NOT NULL,
chan VARCHAR NOT NULL,
nick VARCHAR NOT NULL,
[root@arch bookie]# make run
BOOKIE_INI=bookie.ini bin/python bin/celery worker --app=bookie.bcelery -B -l debug --pidfile celeryd.pid &
bin/python bin/pserve --reload bookie.ini
make: bin/python: Command not found
Makefile:353: recipe for target 'run_app' failed
make: *** [run_app] Error 127
[root@arch bookie]# /bin/sh: bin/python: No such file or directory
boards = [(a,b,c,d,e,f,g,h) |
a <- [1..8],
b <- [x | x <- [1..8], x /= a, x /= a+1, x /= a-1],
c <- [x | x <- [1..8], x /= a, x /= a+2, x /= a-2, x /= b, x /= b+1, x /= b-1],
d <- [x | x <- [1..8], x /= a, x /= a+3, x /= a-3, x /= b, x /= b+2, x /= b-2, x /= c, x /= c+1, x /= c-1],
e <- [x | x <- [1..8], x /= a, x /= a+4, x /= a-4, x /= b, x /= b+3, x /= b-3, x /= c, x /= c+2, x /= c-2, x /= d, x /= d+1, x /= d-1],
f <- [x | x <- [1..8], x /= a, x /= a+5, x /= a-5, x /= b, x /= b+4, x /= b-4, x /= c, x /= c+3, x /= c-3, x /= d, x /= d+2, x /= d-2, x /= e, x /= e+1, x /= e-1],
g <- [x | x <- [1..8], x /= a, x /= a+6, x /= a-6, x /= b, x /= b+5, x /= b-5, x /= c, x /= c+4, x /= c-4, x /= d, x /= d+3, x /= d-3, x /= e, x /= e+2, x /= e-2, x /= f, x /= f+1, x /= f-1],
h <- [x | x <- [1..8], x /= a, x /= a+7, x /= a-7, x /= b, x /= b+6, x /= b-6, x /= c, x /= c+5, x /= c-5, x /= d, x /= d+4, x /= d-4, x /= e, x /= e+3, x /= e-3, x /= f, x /= f+2, x /= f-2, x /= g, x /= g+1, x /= g-1]]
#!/bin/bash
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root" 1>&2
exit 1
fi
FILE="/var/swap-$$.img"
read -p "Size in MB: " SWAPSIZE
echo "Creating file $FILE"
touch $FILE
echo "Allocate $SWAPSIZE MB space for swap on $FILE"
@dyladan
dyladan / video.html
Created April 23, 2013 10:15
simple html5 video tag
<video>
<source src="movie.webm" type='video/webm; codecs="vp8, vorbis"' />
<source src="movie.mp4" type='video/mp4; codecs="avc1.42E01E, mp4a.40.2"' />
<source src="movie.ogv" type='video/ogg; codecs="theora, vorbis"' />
Video tag not supported. Download the video <a href="movie.webm">here</a>.
</video>
@dyladan
dyladan / com.company.xprotect_re-enable_java_6_and_7.plist
Created March 11, 2013 15:42
This should re-enable java 6 and 7 on macs and check the plist ever 15 minutes after startup. Put xprotect_re-enable_java_6_and_7.sh in /Library/Scripts and put com.company.xprotect_re-enable_java_6_and_7.plist in /Library/LaunchDaemons the launch daemon plist should have 644 permissions with owner root and group wheel the script should have per…
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.company.xprotect_re-enable_java_6_and_7</string>
<key>ProgramArguments</key>
<array>
<string>sh</string>
<string>/Library/Scripts/xprotect_re-enable_java_6_and_7.sh</string>
@dyladan
dyladan / sort.rb
Created March 8, 2013 22:11
sorts torrent files into folder by tracker. Just put all your files in a folder called torrents and run this file one level above that folder.
require 'bencode'
require 'fileutils'
Dir.glob('torrents/*.torrent') do |item|
if File.directory?(item)
next
end
tracker = BEncode.load_file(item)["announce"].gsub("http://", "").split('/')[0]
if tracker == nil