Skip to content

Instantly share code, notes, and snippets.

View richo's full-sized avatar

richö butts richo

View GitHub Profile
@mcpherrinm
mcpherrinm / instructions.md
Last active September 6, 2024 05:10
Crosscompiling Rust to Arm

I want to write Rust code on my computer (x86_64, Ubuntu 14.04) and produce arm executables. I found hints on the internet, but not a concise set of instructions on what to do. So I wrote them down exactly:

apt-get install g++-arm-linux-gnueabihf
git clone https://github.com/mozilla/rust.git
mkdir rust/build-cross
cd rust/build-cross
../configure --target=arm-unknown-linux-gnueabihf --prefix=$HOME/local/rust-cross
make -j8 && make install
@panzi
panzi / portable_endian.h
Last active August 9, 2024 13:12
This provides the endian conversion functions form endian.h on Windows, Linux, *BSD, Mac OS X, and QNX. You still need to use -std=gnu99 instead of -std=c99 for gcc. The functions might actually be macros. Functions: htobe16, htole16, be16toh, le16toh, htobe32, htole32, be32toh, le32toh, htobe64, htole64, be64toh, le64toh. License: I hereby put …
// "License": Public Domain
// I, Mathias Panzenböck, place this file hereby into the public domain. Use it at your own risk for whatever you like.
// In case there are jurisdictions that don't support putting things in the public domain you can also consider it to
// be "dual licensed" under the BSD, MIT and Apache licenses, if you want to. This code is trivial anyway. Consider it
// an example on how to get the endian conversion functions on different platforms.
#ifndef PORTABLE_ENDIAN_H__
#define PORTABLE_ENDIAN_H__
#if (defined(_WIN16) || defined(_WIN32) || defined(_WIN64)) && !defined(__WINDOWS__)
irb(main):004:0> x = RubyVM::InstructionSequence.new('puts "hello #{foo}"')
=> <RubyVM::InstructionSequence:<compiled>@<compiled>>
irb(main):005:0> puts x.disasm
== disasm: <RubyVM::InstructionSequence:<compiled>@<compiled>>==========
0000 trace 1 ( 1)
0002 putself
0003 putobject "hello "
0005 putself
0006 opt_send_simple <callinfo!mid:foo, argc:0, FCALL|VCALL|ARGS_SKIP>
0008 tostring
@tarcieri
tarcieri / semiprivate.md
Last active January 18, 2023 01:08
Ed25519-based semi-private keys

Semiprivate Keys

🚨 DANGER: INSECURE! 🚨

This may have seemed like a great idea in 2013, but the repeated "set/clear bits", a.k.a. clamping phases at each level of the hierarchy slowly subtract key strength.

Don't use this as described. Check out Ristretto.

Original text

Semi-private keys are an expansion of the traditional idea

@mattetti
mattetti / gist:4455907
Last active December 10, 2015 15:39
Disable YAML parsing in ActiveSupport's XmlMini to avoid a Rails exploit via a XML payload containing YAML type nodes. I don't know of any apps needing to embed YAML in a XML and getting Rails to auto parse the payload so I think this is a pretty safe patch.
ActiveSupport::XmlMini::FORMATTING.update("yaml" => Proc.new{|yaml| yaml.to_s })
ActiveSupport::XmlMini::PARSING.update("yaml" => Proc.new{|yaml| yaml.to_s })
@lox
lox / watch.rb
Created April 20, 2012 05:57
Watch a local folder and synchronize it with a remote folder over SCP
#!/usr/bin/env ruby
require 'rubygems'
require 'rb-fsevent'
require 'optparse'
require 'net/ssh'
require 'net/sftp'
def watch_directory(sftp, watch_dir, target_dir)
fsevent = FSEvent.new
require 'pry'
require 'drb'
DRb.start_service
client = DRbObject.new nil, ARGV[0]
# Dummy proxy, DRb won't allow us to pass Readline directly.
Proxy = Object.new
@ConradIrwin
ConradIrwin / .vimrc
Created May 6, 2011 03:51
# Comment vim text-object
function! SelectComment()
let curindent = indent(".")
" bail if not a comment
if getline(".")[curindent] != "#"
return
endif
" find the first commented line
while line(".") - 1 && indent(line(".") - 1) == curindent && getline(line(".") - 1)[curindent] == "#"
@quamen
quamen / cached_resource.rb
Created April 29, 2011 02:26
Module that adds read through caching to ActiveResource with fallback to a permanent cache
require 'active_support/concern'
module CachedResource
extend ActiveSupport::Concern
included do
class << self
alias_method_chain :find, :cache
end