Skip to content

Instantly share code, notes, and snippets.

Thomas Bruyelle tbruyelle

Block or report user

Report or block tbruyelle

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View Makefile
APP = ???
PACKAGE = github.com/???/???
BIN = $(PACKAGE)/cmd/???
TARGET = `go list $(PACKAGE)/... | grep -v vendor`
SRC_DIR = ???
default: build
include checks.mk
View checks.mk
checks:
go test -race $(TARGET)
@$(call checkbin,go tool vet,golang.org/x/tools/cms/vet)
go tool vet $(SRC_DIR)
@$(call checkbin,golint,github.com/golang/lint/golint)
golint -set_exit_status $(SRC_DIR)
@$(call checkbin,errcheck,github.com/kisielk/errcheck)
errcheck -ignore 'Close' -ignoretests $(TARGET)
@$(call checkbin,structcheck,github.com/opennota/check/cmd/structcheck)
structcheck $(TARGET)
View aescbc.go
package main
import (
"crypto/aes"
"crypto/cipher"
"crypto/md5"
"encoding/base64"
"fmt"
)
View fix-emulator.sh
ln -sf /usr/lib/libstdc++.so.6 ~/Android/Sdk/tools/lib64/libstdc++/libstdc++.so.6
View distinct.js
.debounce(100)
.filter(val -> {
if (allKeys[val]) {
allKeys[val] = false;
return true;
}
return false;
})
View ListViewUtil.java
public View getViewByPosition(int pos, ListView listView) {
final int firstListItemPosition = listView.getFirstVisiblePosition();
final int lastListItemPosition = firstListItemPosition + listView.getChildCount() - 1;
if (pos < firstListItemPosition || pos > lastListItemPosition ) {
return listView.getAdapter().getView(pos, null, listView);
} else {
final int childIndex = pos - firstListItemPosition;
return listView.getChildAt(childIndex);
}
View tmpl.go
func tmpl(w io.Writer, text string, data interface{}) {
t := template.New("top")
t.Funcs(template.FuncMap{
"trim": strings.TrimSpace,
// deref allows to use pointer in templates
"deref": func(data interface{}) string {
if reflect.ValueOf(data).IsNil() {
return ""
}
switch vv := data.(type) {
View GetHashMapResource.java
public static Map<String, String> getHashMapResource(Context c, int hashMapResId) {
Map<String, String> map = null;
XmlResourceParser parser = c.getResources().getXml(hashMapResId);
String key = null, value = null;
try {
int eventType = parser.getEventType();
while (eventType != XmlPullParser.END_DOCUMENT) {
View AppCompatPreferenceActivity.java
/*
* Copyright (C) 2014 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
View divider.xml
<View
android:id="@+id/divider"
android:layout_width="match_parent"
android:layout_height="1px"
android:layout_gravity="bottom"
android:layout_marginLeft="72dp"
android:background="#9e9e9e"
android:src="@android:drawable/divider_horizontal_dim_dark"
/>
You can’t perform that action at this time.