Skip to content

Instantly share code, notes, and snippets.

View nacho4d's full-sized avatar

Guillermo Ignacio Enriquez Gutierrez nacho4d

View GitHub Profile
@nacho4d
nacho4d / worklight.log
Created August 27, 2015 07:31
long stack trace
[8/27/15 15:53:39:235 JST] 0000008b ication.internal.jaas.modules.UsernameAndPasswordLoginModule A CWWKS1100A: Authentication did not succeed for user ID oLs3jn4fNG. An invalid user ID or password was specified.
[8/27/15 15:53:39:350 JST] 000000b0 SystemErr R java.util.zip.ZipException: zip file is empty
[8/27/15 15:53:39:350 JST] 000000b0 SystemErr R at java.util.zip.ZipFile.open(Native Method)
[8/27/15 15:53:39:351 JST] 000000b0 SystemErr R at java.util.zip.ZipFile.<init>(ZipFile.java:220)
[8/27/15 15:53:39:351 JST] 000000b0 SystemErr R at java.util.zip.ZipFile.<init>(ZipFile.java:150)
[8/27/15 15:53:39:351 JST] 000000b0 SystemErr R at java.util.jar.JarFile.<init>(JarFile.java:166)
[8/27/15 15:53:39:351 JST] 000000b0 SystemErr
@nacho4d
nacho4d / AndroidManifestEditor.sh
Created February 20, 2014 11:03
Edit AndroidManifest.xml using xmlstarlet
#! /bin/bash
set -e;
[ -z "$1" ] && { echo "ERROR: No AndroidManifest.xml provided"; exit 1; }
command -v xmlstarlet >/dev/null 2>&1 || { echo >&2 "ERROR: xmlstarlet command not available"; exit 1; }
MANIFEST_FILE=$1
function addUsesPermission ()
@nacho4d
nacho4d / .profile
Last active August 29, 2015 13:58
Genereal coloriser configuration file for Android Debug Bridge: Create a file in `~/.grc/conf.adb` and add adb entry to `/usr/local/etc/grc.conf`
# Add path for Android
export ANDROID_HOME=$HOME/Downloads/adt-bundle-mac-x86_64-20140321/sdk
export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
@nacho4d
nacho4d / tangotangolight-theme.el
Created July 29, 2014 10:24
tangotangolight-theme.el
;;; tangotangolight-theme.el --- Tango Palette color theme for Emacs 24.
;; First derived from color-theme-tango.el, created by danranx@gmail.com :
;; http://www.emacswiki.org/emacs/color-theme-tango.el
;; Copyright (C) 2011, 2012, 2013 Julien Barnier <julien@nozav.org>
;; Author: Julien Barnier
;; Adapted-By: Yesudeep Mangalapilly
;; Keywords: tango palette color theme emacs
@nacho4d
nacho4d / femacs
Last active August 29, 2015 14:10
find and open in emacs
#! /bin/bash
# Place this file somewhere in your $PATH and chmod +x it!
function usage () {
echo "Usage:"
echo "femacs is 'find and open in emacs'"
echo "femacs requires 1 parameter. It basically does:"
echo " emacs \`find . -name [expression]\`";
}
@nacho4d
nacho4d / compile.sh
Created December 16, 2014 07:48
Compile file for C# CodeRunner. It runs even when gmcs gives warnings. (After showing them)
#!/bin/bash -x
# This is a CodeRunner compilation script. Compilation scripts are used to
# compile code before being run using the run command specified in CodeRunner
# preferences. This script should have the following properties:
#
# Launch directory ($PWD): Will be the same as the file being run
#
# Exit status: Should be 0 on success (will cause CodeRunner
# to continue and execute the run command)
#
@nacho4d
nacho4d / MajorityElement
Last active August 29, 2015 14:12
Majority element
// https://oj.leetcode.com/problems/majority-element/
// Given an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋ times.
// You may assume that the array is non-empty and the majority element always exist in the array.
class Solution {
public:
// Hash table
int majorityElement_hashtable(vector<int> &num) {
std::map <int, int> table;
for (int n : num) {
$ swiftc -emit-ir /Users/nacho4d/Desktop/function2/function2/main.swift -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk
; ModuleID = '-'
target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-apple-darwin14.0.0"
%0 = type opaque
%1 = type opaque
%Si = type <{ i64 }>
%CSo8NSObject = type opaque
%swift.type = type { i64 }
// There is a bug in WebKit
// Local files cannot be read unless they are in the tmp/www/ directory!
// Example: read "file.pdf" into WKWebView
var fileManager = NSFileManager.defaultManager()
var srcPath = NSBundle.mainBundle().pathForResource("file", ofType: "pdf")
var tmpPath = NSTemporaryDirectory().stringByAppendingPathComponent("www")
// TODO: handler errors correctly
fileManager.createDirectoryAtPath(tmpPath, withIntermediateDirectories: true, attributes: nil, error: nil)
var dstPath = tmpPath.stringByAppendingPathComponent("file.pdf")
@nacho4d
nacho4d / NSView2PNG
Created October 13, 2011 06:48
[Cocoa] NSView to PNG
/* NSView to PNG */
NSView *view = versionsButton; /* this is the view :) */
NSBitmapImageRep *rep = [view bitmapImageRepForCachingDisplayInRect:[view bounds]];
[view cacheDisplayInRect:[view bounds] toBitmapImageRep:rep];
NSData *data = [rep representationUsingType:NSPNGFileType properties:nil];
[data writeToFile:@"/path/to/the/a/nice/place/view.png" atomically:YES];