Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

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

To claim this, I am signing this object:

Keybase proof

I hereby claim:

  • I am eferm on github.
  • I am eferm (https://keybase.io/eferm) on keybase.
  • I have a public key whose fingerprint is 1E69 84BB D26B 0C0E 8A2C 0AA7 5821 2741 B3A9 2FF4

To claim this, I am signing this object:

@eferm
eferm / numbers-export-csv.sh
Created April 9, 2018 16:17 — forked from timlien/numbers-export-csv.sh
Export mac numbers file into csv format with apple script
#!/usr/bin/osascript
on run argv
set theFilePath to POSIX file (item 1 of argv)
set theFolder to theFilePath as alias
tell application "Finder" to set theDocs to theFolder's items
-- Avoid export privilege problem
set privilegeFile to (theFolder as text) & ".permission"
std::pair <int, int>* slot = new std::pair <int, int>;
bool overwrite = get_used_slot(_key, slot);
if (!overwrite) {
int length = key_length + value_length + REC_LEN;
if (!pop_free_slot(length, slot)) { // reuse gaps in file
slot->first = get_tail_offset(length); // append to EOF
slot->second = length;
}
}
@eferm
eferm / persistence.cc
Created April 12, 2011 14:01
keep_on_writing
void Persistence::keep_on_writing()
{
while (!stop) {
boost::unique_lock<boost::mutex> lock(wait_mutex);
while (write_jobs.empty() && !stop) {
job_arrive.wait(lock);
}
boost::unique_lock<boost::mutex> lock2(write_jobs_mutex);
std::vector <write_job*> batch (write_jobs.size());
@eferm
eferm / persistence.cc
Created April 12, 2011 13:58
persist_write
bool Persistence::persist_write(const char* key, size_t key_length,
const char* value, size_t value_length)
{
/* boring code removed */
write_job* job = new write_job;
bool finished = false;
job->buf = buf;
job->slot = job_slot;
/** A job for the writer thread. */
struct write_job {
char* buf;
std::pair <int, int>* slot;
bool* finished;
};
say -v "Bad News" 27182818 | say -v "Good News" 1 1 2 3 4 5 | say -v Deranged 161803398874989
public static String explode(String ascii) {
// output string dimensioned for typical output size
StringBuilder output = new StringBuilder(RATIO*ascii.length());
for (int i = 0; i < ascii.length(); i++) {
String num = ascii.substring(i,i+1); // number to be hidden
// next occurence of num in pi at what index?
int index = pi.indexOf(num, INTERVAL+output.length());