Skip to content

Instantly share code, notes, and snippets.

View lazercorn's full-sized avatar

Mike lazercorn

  • Google
View GitHub Profile
0 = Success
1 = Operation not permitted
2 = No such file or directory
3 = No such process
4 = Interrupted system call
5 = Input/output error
6 = No such device or address
7 = Argument list too long
8 = Exec format error
@lazercorn
lazercorn / edittext.java
Created January 27, 2018 05:08 — forked from Reacoder/edittext.java
EditText onClick event is not triggering
When a user interacts with a UI element the various listeners are called in a top down order. (For example: OnTouch -> OnFocusChange -> OnClick.) If a listener has been defined (with setOn...Listener) and it consumes this event: the lower priority listeners will not be called. By its nature the first time you touch an EditText it receives focus with OnFocusChangeListener so that the user can type. The action is consumed here therefor OnClick is not called. Each successive touch doesn't change the focus so the event trickles down to the OnClickListener.
Basically, you have three choices:
Set the focusable attribute to false in your XML:
android:focusable="false"
Now the OnClickListener will fire every time it is clicked. But this makes the EditText useless since the user can no longer enter any text...
Implement an OnFocusChangeListener along with the OnClickListener:
@lazercorn
lazercorn / Haversine.md
Created December 28, 2017 15:22 — forked from broox/Haversine.md
Haversine Distance Formulas

Haversine Formula

used to calculate the great circle distance between two points on the earth (specified in decimal degrees)

Earth's Radius

  • Miles: 3956
  • Kilometers: 6371

Javascript

@lazercorn
lazercorn / encode_uri_rfc3986.erl
Created November 29, 2017 00:53 — forked from renatoalbano/encode_uri_rfc3986.erl
erlang percent encoding that works with utf-8
-module(encode_uri_rfc3986).
-author('Renato Albano <renatoalbano@gmail.com>').
-export([encode/1]).
%% Taken from <http://erlangexamples.com/>,
%% from <http://github.com/CapnKernul/httparadise>
%% and <http://www.erlang.org/doc/man/edoc_lib.html>
encode([C | Cs]) when C >= $a, C =< $z ->
@lazercorn
lazercorn / gist:6c3ae646b6455fea279ecdc44d88ff3e
Created November 26, 2017 00:58 — forked from mediavrog/gist:5625602
Filter out Intents you don"t want to show from a IntentChooser dialog. For example your own app, competing apps or just apps you have a share integration by SDK already :) Based on http://stackoverflow.com/questions/5734678/custom-filtering-of-intent-chooser-based-on-installed-android-package-name/8550043#8550043
// Usage:
// blacklist
String[] blacklist = new String[]{"com.any.package", "net.other.package"};
// your share intent
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_TEXT, "some text");
intent.putExtra(android.content.Intent.EXTRA_SUBJECT, "a subject");
// ... anything else you want to add
// invoke custom chooser
@lazercorn
lazercorn / main.go
Created November 17, 2017 05:53 — forked from tonyhb/main.go
Golang: Converting a struct to a map (to a url.Values string map)
package main
import (
"fmt"
"net/url"
"reflect"
"strconv"
)
type Person struct {
@lazercorn
lazercorn / vpn.md
Created October 13, 2017 03:14 — forked from joepie91/vpn.md
Don't use VPN services.

Don't use VPN services.

No, seriously, don't. You're probably reading this because you've asked what VPN service to use, and this is the answer.

Note: The content in this post does not apply to using VPN for their intended purpose; that is, as a virtual private (internal) network. It only applies to using it as a glorified proxy, which is what every third-party "VPN provider" does.

(A Russian translation of this article can be found here, contributed by Timur Demin.)

Why not?

@lazercorn
lazercorn / golang_job_queue.md
Created October 11, 2017 02:21 — forked from harlow/golang_job_queue.md
Job queues in Golang
This file has been truncated, but you can view the full file.
{"1585790": 3.4166666666666665, "2484454": 4.05531914893617, "756299": 3.1350397175639895, "1654988": 4.204081632653061, "1509115": 3.8620689655172415, "2544239": 4.081632653061225, "2628112": 4.261363636363637, "106251": 3.627906976744186, "1908123": 3.1584158415841586, "956405": 3.815165876777251, "1677102": 2.625, "1816136": 3.5789473684210527, "608713": 3.129032258064516, "1380944": 3.543859649122807, "1057084": 3.524534686971235, "321898": 3.2653061224489797, "2262698": 3.675324675324675, "2548609": 3.0258620689655173, "1565111": 3.5835189309576836, "1745025": 3.7710843373493974, "680501": 3.8565400843881856, "1711213": 3.5025641025641026, "850822": 3.8, "377801": 3.8860759493670884, "1527866": 3.9789156626506026, "1347752": 3.975609756097561, "9064": 4.11214953271028, "614622": 4.03030303030303, "2051622": 3.512987012987013, "1742509": 3.6, "2457665": 4.072847682119205, "1410167": 3.590909090909091, "1557557": 3.1462072958888245, "608569": 3.796116504854369, "2206438": 3.4651162790697674, "2405827": 4.7