Skip to content

Instantly share code, notes, and snippets.

@grieve
grieve / dropshot.py
Created July 10, 2012 12:55
Simple hack to use gnome-screenshot and dropbox to upload quick public screenshots - required libnotify-bin for notifications
#!/usr/bin/python
import gtk
import simplejson
import urllib2
import subprocess
import datetime
import string
import random
import time
public EdgeEffect(Context context) {
final Resources res = context.getResources();
mEdge = res.getDrawable(R.drawable.overscroll_edge);
mGlow = res.getDrawable(R.drawable.overscroll_glow);
@rawsh
rawsh / tint2rc
Last active May 19, 2018 01:46
tint2rc
#---- Generated by tint2conf 9757 ----
# See https://gitlab.com/o9000/tint2/wikis/Configure for
# full documentation of the configuration options.
#-------------------------------------
# Backgrounds
# Background 1: Panel, Tooltip
rounded = 0
border_width = 0
border_sides = TBLR
background_color = #16161d 63
@juanchosaravia
juanchosaravia / KotlinParcelable
Last active February 28, 2019 12:10
How to use Parcelable in Kotlin v1.0.0-beta-4589
// ------------ Helper extension functions:
// Inline function to create Parcel Creator
inline fun <reified T : Parcelable> createParcel(crossinline createFromParcel: (Parcel) -> T?): Parcelable.Creator<T> =
object : Parcelable.Creator<T> {
override fun createFromParcel(source: Parcel): T? = createFromParcel(source)
override fun newArray(size: Int): Array<out T?> = arrayOfNulls(size)
}
// custom readParcelable to avoid reflection
@johndgiese
johndgiese / winstonConfig.js
Last active May 6, 2019 09:09
Make node's winston logger print stack traces
// Extend a winston by making it expand errors when passed in as the
// second argument (the first argument is the log level).
function expandErrors(logger) {
var oldLogFunc = logger.log;
logger.log = function() {
var args = Array.prototype.slice.call(arguments, 0);
if (args.length >= 2 && args[1] instanceof Error) {
args[1] = args[1].stack;
}
return oldLogFunc.apply(this, args);
var download = require('./lib/download');
download('http://meuarquivolocodedoido.com.br/arquivo.txt', './downloads')
.then(function(id){
console.log('Arquivo gravado com id %s', id);
})
.catch(function(err){
console.log('Deu pau..');
console.log(err.stack);
});
@tinmegali
tinmegali / LiveData.ext.kt
Created July 14, 2017 19:14
Kotlin extension to allow Unit tests on Android LiveData
package com.tinmegali.daggerwithkotlin.room
import android.arch.lifecycle.LiveData
import android.arch.lifecycle.Observer
import java.util.concurrent.CountDownLatch
import java.util.concurrent.TimeUnit
// Extension to allow unit tests on LiveData
// discussion on: https://stackoverflow.com/questions/44270688/unit-testing-room-and-livedata
@Unibozu
Unibozu / README.md
Last active September 8, 2021 06:31
Shutter - Linux - dropbox automatic screenshot url to clipboard

Shutter - Dropbox automatic screenshot URL to Clipboard

Installation

  1. Configure shutter to save your screenshot directly intoyour dropbox public folder.
  2. Place dropbox-puburl.sh in the location of your choice (here ~/tools/bin/dropbox-puburl.sh)
  3. Place dropbox-screenshot-puburl.desktop into /usr/share/applications (you need to be root)
  4. Eventually update the path to your Bash script
  5. exec sudo update-desktop-database
  6. Quit and restart shutter. Go into Preferences &gt; Actions &gt; Open With and select Dropbox copy public file URL to clipboard
@duydo
duydo / elasticsearch_best_practices.txt
Last active December 15, 2021 06:12
Elasticsearch - Index best practices from Shay Banon
If you want, I can try and help with pointers as to how to improve the indexing speed you get. Its quite easy to really increase it by using some simple guidelines, for example:
- Use create in the index API (assuming you can).
- Relax the real time aspect from 1 second to something a bit higher (index.engine.robin.refresh_interval).
- Increase the indexing buffer size (indices.memory.index_buffer_size), it defaults to the value 10% which is 10% of the heap.
- Increase the number of dirty operations that trigger automatic flush (so the translog won't get really big, even though its FS based) by setting index.translog.flush_threshold (defaults to 5000).
- Increase the memory allocated to elasticsearch node. By default its 1g.
- Start with a lower replica count (even 0), and then once the bulk loading is done, increate it to the value you want it to be using the update_settings API. This will improve things as possibly less shards will be allocated to each machine.
- Increase the number of machines you have so
@sam33rdhakal
sam33rdhakal / HowdysRealmSerializerGenerator.java
Last active December 17, 2021 16:22
Script for generating RealmObject Serializer. Uses JavaPoet to write file.
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer;
import com.squareup.javapoet.*;
import javax.lang.model.element.Modifier;
import java.io.File;
import java.io.IOException;
import java.lang.reflect.Field;