Skip to content

Instantly share code, notes, and snippets.

@pesterhazy
pesterhazy / into
Created June 23, 2015 08:51
redirect output to a file without ">"
#!/usr/bin/env bash
#
# Save to /usr/bin/into
#
# Usage: into output.txt tac input.txt
#
set -euo pipefail
to="$1"
@pesterhazy
pesterhazy / csv2xls
Last active August 29, 2015 14:23
csv2xls: convert CSV file to XLS (Excel 2007 format) on the command line
#!/usr/bin/env bash
#
# You need gnumeric installed, which provides the
# ssconvert tool (on Ubuntu: sudo apt-get install gnumeric)
#
# Usage:
#
# generate_csv | csv2xls > out.xls
Fatal error: Uncaught exception 'Zend_Controller_Action_Exception' with message 'Forbidden' in /var/www/findfriends.openunivercity.de/application/plugins/Auth.php:61 Stack trace: #0 /opt/ZendFramework-1.11.1/library/Zend/Controller/Plugin/Broker.php(309): Application_Plugin_Auth->preDispatch(Object(Zend_Controller_Request_Http)) #1 /opt/ZendFramework-1.11.1/library/Zend/Controller/Front.php(941): Zend_Controller_Plugin_Broker->preDispatch(Object(Zend_Controller_Request_Http)) #2 /opt/ZendFramework-1.11.1/library/Zend/Application/Bootstrap/Bootstrap.php(97): Zend_Controller_Front->dispatch() #3 /opt/ZendFramework-1.11.1/library/Zend/Application.php(366): Zend_Application_Bootstrap_Bootstrap->run() #4 /var/www/findfriends.openunivercity.de/public/index.php(36): Zend_Application->run() #5 {main} thrown in /var/www/findfriends.openunivercity.de/application/plugins/Auth.php on line 61
--- tmp/flashcache 2011-03-14 03:49:35.000000000 +0100
+++ bin/flashcache 2011-04-29 19:39:37.000000000 +0200
@@ -57,6 +57,7 @@
while (my $arg=shift(@ARGV)) {
if ($arg =~ /^-h$/) { usage(); }
if ($arg =~ /^-d$/) { $MAIN::DEBUG=1; next; }
+ if ($arg =~ /^-p$/) { $MAIN::PLAY=1; next; }
if ($arg =~ /^-find$/) { $opt->{find} = shift(@ARGV); next; }
if ($arg =~ /^-post$/) { $opt->{post} = shift(@ARGV); next; }
if ($arg =~ /^-dest$/) { $opt->{dest} = shift(@ARGV); next; }
@pesterhazy
pesterhazy / nuke-certs.sh
Created February 16, 2016 11:18
Reset code signing certificates to fix builds using `gym`
#!/usr/bin/env bash
# nuke-certs
#
#
# This script has been reported to help with errors like
#
# this:
# + xcodebuild -exportArchive -exportOptionsPlist /var/folders/rj/8lnf662s3mlgzv5mcq2r2fnc0000gn/T/gym20160216-41694-14bt0ur_config.plist -archivePath '/Users/pe/Library/Developer/Xcode/Archives/2016-02-16/016-02-16 12.09.02.xcarchive' -exportPath /var/folders/rj/8lnf662s3mlgzv5mcq2r2fnc0000gn/T/gym20160216-41694-17mfck9.gym_output
# 2016-02-16 12:10:03.004 xcodebuild[43629:464102] [MT] IDEDistribution: -[IDEDistributionLogging _createLoggingBundleAtPath:]: Created bundle at path '/var/folders/rj/8lnf662s3mlgzv5mcq2r2fnc0000gn/T/016-02-16_12-10-03.003.xcdistributionlogs'.
@pesterhazy
pesterhazy / group-by-keys.clj
Created April 13, 2016 13:16
Group a map by one or more keys
(defn group-by-keys
"Group maps by a set of keys. For each key not grouped, all values are
returned as a set"
[ms kys]
(let [kys (set kys)
grouped (group-by #(select-keys % kys) ms)]
(map (fn [[pk pv]]
(into pk
(reduce (fn [a [k v]] (update a k #(conj (or % #{}) v)))
{}
;; Display arbitrary EDN-like values in a browser
;;
;; See https://github.com/yogthos/json-html
;;
;; in project.clj / build.boot:
;; [json-html "0.3.9"]
;; [hiccup "1.0.5"]
(require '[json-html.core :as jh]
'[hiccup.page])
boot-react-native/example$ boot -v dev
registering react-support [:create :modify :delete]
registering react-support/cljsjs [:create :modify :delete]
registering src [:create :modify :delete]
registering src/mattsum [:create :modify :delete]
registering src/mattsum/simple_example [:create :modify :delete]
sending change event
Syncing project dirs to temp dirs...
Acquired java.util.concurrent.Semaphore@68567e20[Permits = 0]...
@pesterhazy
pesterhazy / react-native-only.py
Created August 5, 2016 13:55
Filter "react-native log-ios" output for relevant app logs
#!/usr/bin/env python
# Cleans up the output of "react-native log-ios" by
# removing all output not related to your app, similarly
# to how it works in the XCode debug window
#
# Usage: react-native log-ios | ./react-native-only.py "<string>"
#
# where "<string>" is the name of your app as known
# to the iOS logging system. E.g. "SimpleExampleApp"
@pesterhazy
pesterhazy / boot-react-native-no-dev.py
Created August 17, 2016 18:13
Set __DEV__ of RN packager output to false
#!/usr/bin/env python
#
# boot-react-native-no-dev.py
#
# Patch jsbundle to set __DEV__ to false
#
# The React Native packager often cannot handle Google Closure-generated JS files
# if `--dev false` is set, eventually running out of memory. As a workaround,
# use `--dev true` and patch the __DEV__ setting in the output bundle to
# false.