This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::ffi::CString; | |
trait ReadByteString { | |
fn read_string_zero(&self) -> Option<CString> ; | |
} | |
impl ReadByteString for [u8] { | |
fn read_string_zero(&self) -> Option<CString> { | |
let pos = self.iter().position(|&x| x == 0 )?; | |
CString::new(&self[..pos]).ok() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "openssl" | |
require "digest" | |
def aes128_encrypt(key, data) | |
key = Digest::MD5.digest(key) if(key.kind_of?(String) && 16 != key.bytesize) | |
aes = OpenSSL::Cipher.new('AES-128-CBC') | |
aes.encrypt | |
aes.key = key | |
aes.update(data) + aes.final | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] | |
struct ParseError; | |
macro_rules! enum_with_str_representation { | |
(enum $enum_name:ident { | |
$($variant:ident => $nice_name:expr,)+ | |
}) => { | |
#[derive(Debug, PartialEq, Eq, Clone, Hash)] | |
enum $enum_name { | |
$($variant),+ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Let's build rust programs with msvc linker! | |
// Started by klutzy | |
// Continued by Retep998 | |
// Command line | |
/* | |
SET PATH=C:\WINDOWS;C:\WINDOWS\System32;C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\amd64;A:\rust64\bin;A:\LLVM\bin | |
rustc libcore\lib.rs --target=x86_64-pc-windows -Car=llvm-ar | |
rustc test.rs --emit=obj --target=x86_64-pc-windows --extern core=libcore.rlib | |
link "test.o" "libcore.rlib" "kernel32.lib" "user32.lib" "gdi32.lib" "winspool.lib" "comdlg32.lib" "advapi32.lib" "shell32.lib" "ole32.lib" "oleaut32.lib" "uuid.lib" "odbc32.lib" "odbccp32.lib" "libcmt.lib" /LIBPATH:"C:\Program Files (x86)\Windows Kits\8.1\Lib\winv6.3\um\x64" /LIBPATH:"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\lib\amd64" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Windows Registry Editor Version 5.00 | |
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout] | |
"Scancode Map"=hex:00,00,00,00,00,00,00,00,03,00,00,00,00,00,5B,E0,00,00,5C,E0,00,00,00,00 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Unit] | |
Description=Puma Rails Server | |
After=network.target | |
[Service] | |
Type=simple | |
User=deploy | |
WorkingDirectory=/home/deploy/app/current | |
ExecStart=/home/deploy/.rbenv/bin/rbenv exec bundle exec puma -C /home/deploy/app/shared/config/puma.rb | |
ExecStop=/home/deploy/.rbenv/bin/rbenv exec bundle exec pumactl -S /home/deploy/app/shared/tmp/pids/puma.state stop |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# based on https://gist.github.com/twtw/5494223 | |
# create systemd service file for rails/puma startup | |
# 0. [if required: rvm use ruby@default] | |
# 1. rvm wrapper default systemd rails | |
# 2. put this file in /etc/systemd/system/rails-puma.service | |
# 3. systemctl enable rails-puma | |
# 4. systemctl start rails-puma | |
[Unit] | |
Description=Rails-Puma Webserver | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Ruby = 5.times { |i| puts i } | |
// JS = (1).times(function(i){console.log(i);}) | |
Number.prototype.times = function(cb) { | |
var i = -1; | |
while (++i < this) { | |
cb(i); | |
} | |
return +this; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# PowerShell function to run JavaScript/JQuery and return results back to PS, with timeout | |
# some web page with jQuery in it | |
$url = "http://jquery.com/" | |
Function ResetTimer | |
{ | |
$script:startTime = [DateTime]::Now | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rvm osx-ssl-certs update | |
gem update --system |