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
#include <stdio.h> | |
#include <sodium/crypto_box.h> | |
#include <sodium/randombytes.h> | |
int main(int argc, char *argv[]) { | |
// payload | |
unsigned char payload[] = "Hello world, this is a test payload to test NaCl's cipher."; | |
unsigned char payload_padded[crypto_box_ZEROBYTES + sizeof(payload)] = {0}; | |
for (int i = 0; i < sizeof(payload); i++) |
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
// out must be cb_b642bytes_outsize(sizeof(in)-1) aka cb_b642bytes_outsize(strlen(in)) | |
// returns length of out, (which *may* be zero-padded) if return val > cb_b642bytes_outsize | |
static inline int cb_b642bytes_outsize(int insize) { return ((insize-insize%4)+(insize%4==0?0:4))/4*3; } | |
int cb_b642bytes(unsigned char *out, const char *in); | |
// out must be cb_bytes2b64_outsize(sizeof(in)) | |
// returns null-terminated string | |
static inline int cb_bytes2b64_outsize(int insize) { return ((insize-insize%3)+(insize%3==0?0:3))/3*4+1; } | |
void cb_bytes2b64(char *out, const unsigned char *in, int in_length); |
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
#!/usr/bin/env ruby | |
require 'scout_api' | |
group_name = ARGV[0] | |
Scout::Account.new('...', '...', '...') | |
all_servers = Scout::Server.all(group_name: 'API') |
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
typedef void(^CBOfflineCacheContentFetcher)(CBOfflineCacheFetchedContentCallback callback); | |
typedef void(^CBOfflineCacheFetchedContentCallback)(BOOL success, NSDictionary *content); | |
typedef void(^CBOfflineCacheCallback)(BOOL success, NSDictionary *content); | |
[CBOfflineCache fetchContent:@"store-view-boosts" | |
withFetcher:^(CBOfflineCacheFetchedContentCallback callback){ | |
// this code does the network access |
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 'validations/version' | |
module Validations | |
module ClassMethods | |
# Doubles as setter & getter for @validations | |
# This method is also the main interface to this lib. | |
# | |
def validations(&block) |
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
package main | |
import ( | |
"errors" | |
"fmt" | |
"io/ioutil" | |
"strings" | |
) | |
const ( |
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
Do it up to fib # 20... | |
About to generate # 20 | |
About to generate # 19 | |
About to generate # 18 | |
About to generate # 17 | |
About to generate # 16 | |
About to generate # 15 | |
About to generate # 14 | |
About to generate # 13 | |
About to generate # 12 |
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
// | |
// Fibonacci generator in C with Y-Combinator powered memoization. | |
// | |
// Written by Kenneth Ballenegger in 2013 | |
// | |
#include <stdlib.h> | |
#include <stdio.h> | |
#include <Block.h> |
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
unless File.open('/tmp/transactions.lock', File::RDWR|File::CREAT, 0644).flock(File::LOCK_EX|File::LOCK_NB) | |
puts 'Cannot lock: Another instance of this script is probably running.' | |
exit | |
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
require 'open3' | |
command = 'ruby test2.rb' | |
(1..2).map do |n| | |
Thread.new do | |
puts "Executing scheduled command: #{command}" | |
output, status = Open3.capture2e(command) | |
unless status.success? |