Skip to content

Instantly share code, notes, and snippets.

@ayosec
ayosec / GitHub API - Preview markdown
Created September 20, 2015 06:36
GitHub API - Preview markdown
curl -H 'Content-Type: text/x-markdown' https://api.github.com/markdown/raw --data-binary @FILE,md > OUTOUT.html
@ayosec
ayosec / x11-change-opacity.sh
Created September 7, 2015 18:49
X11: Set Opacity
window=0x00.....
opacity=30 # Something between 0 and 100
xprop -id $window \
-f _NET_WM_WINDOW_OPACITY 32c \
-set _NET_WM_WINDOW_OPACITY $(($opacity*0xffffffff/100))
#!/bin/sh
exec xterm -geometry 20x10 -T Calculator -fs 25 -fa 'Droid Sans Mono' -bg '#b9c093' -fg black -e irb
@ayosec
ayosec / cypher.rb
Last active August 29, 2015 14:26
Launch Cypher queries
#!/usr/bin/env ruby
case ARGV.size
when 1
host = ARGV[0]
body = STDIN.read
when 2
host = ARGV[0]
body = ARGV[1]
else
use async::fs::File;
use async::io::Async;
fn copy(src: &Path, dst: &Path) -> impl Async<()> {
let src = try!(File::open(src));
let dst = try!(File::create(dst));
// Copy a kiB at a time.
let mut buffer = Vec::with_capacity(1024);
loop {
@ayosec
ayosec / fix-gnome-316-double-click-selection.md
Last active June 12, 2016 16:45
Fix useless double-click selection in Gnome 3.16

New versions of Gnome have a broken behavior for double-click selections. Strings like URLs can'be be selected with double-click, as usual.

The correct behavior can be restored with:

$ dconf write  \
    /org/gnome/terminal/legacy/profiles:/:${PROFILE}/word-char-exceptions \
    '@ms ":-,.;/?%&#_=+@~·"'

See https://bugzilla.gnome.org/show_bug.cgi?id=730632#c33

@ayosec
ayosec / Gemfile
Last active August 29, 2015 14:23
Ruby / EventSource
source "https://rubygems.org"
@ayosec
ayosec / sso.rs
Created June 1, 2015 12:24
Small string in Rust
use std::mem;
use std::fmt::Write;
fn dump_bytes<T>(val: &T) -> String {
let mut output = String::new();
let bytes = unsafe {
let pointer: *const u8 = std::mem::transmute(val);
std::slice::from_raw_parts(pointer, std::mem::size_of::<T>())
};
@ayosec
ayosec / s3_url.rb
Created April 29, 2015 01:10
Presigned URL to download objects from S3
require "openssl"
require "base64"
access_key = ".........."
secret_key = "..................."
s3_object = "$BUCKET/$PATH"
expires = (Time.now + 300).to_i # 5 minutes
data = %[GET\n\n\n#{expires}\n/#{s3_object}]