Skip to content

Instantly share code, notes, and snippets.

@goofyahead
goofyahead / gist:7459592
Last active December 28, 2015 06:49
Pagination of elements with redis
var likes = [1,1,1,4,5,6,7,8,9];
var response = false;
client.sadd('temp:comparator', likes, function (err, data) {
client.sdiff('temp:comparator', 'set:zara', function (err, data) {
console.log(data);
if (data.length > 0) {
client.sadd('set:zara', data, redis.print);
client.del('temp:comparator', redis.print);
data.forEach(function (elem) {
import java.util.ArrayList;
import java.util.List;
/**
* Generic enabled Object Oriented Switch/Case construct
* @param <T> type to switch on
*/
public class Switch<T extends Comparable<T>>
{
private final List<Case<T>> cases;
android.libraryVariants.all { variant ->
def name = variant.buildType.name
if (name.equals(com.android.builder.BuilderConstants.DEBUG)) {
return; // Skip debug builds.
}
def task = project.tasks.create "jar${name.capitalize()}", Jar
task.dependsOn variant.javaCompile
//Include Java classes
task.from variant.javaCompile.destinationDir
//Include dependent jars with some exceptions
sudo add-apt-repository ppa:chris-lea/zeromq
sudo apt-get update
sudo apt-get install libzmq3-dbg libzmq3-dev libzmq3
I found a solution for the OSMC start/stop issue using openvt & nohup. Thanks to mkobit for the OSMC/RetroPie scripts (https://github.com/mcobit/retropie-osmc).
First we need to install kdb & libopus-dev:
apt-get update
apt-get install kbd
apt-get install libopus-dev
Code of my scripts:
/home/limelight/limelight.sh:
@goofyahead
goofyahead / index.html
Created December 16, 2015 19:26
jWWdxV
<html>
<head>
<title>About Me</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="http://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600,700" rel="stylesheet">
<link rel="stylesheet" href="styles.css">
</head>
<body>
<main>
@goofyahead
goofyahead / AndroidManifest.xml
Last active July 12, 2016 11:06
Sample for dagger 2 in android
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="socialtech.com.triboo"
>
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
@goofyahead
goofyahead / BitmapScaler.java
Last active September 7, 2016 12:12 — forked from nesquena/BitmapScaler.java
Easy utility for scaling bitmaps
public class BitmapScaler
{
// scale and keep aspect ratio
public static Bitmap scaleToFitWidth(Bitmap b, int width)
{
float factor = width / (float) b.getWidth();
return Bitmap.createScaledBitmap(b, width, (int) (b.getHeight() * factor), true);
}
@goofyahead
goofyahead / Place.js
Created September 15, 2016 14:53 — forked from PascalAnimateur/Place.js
Geospatial example in Sails.js using native MongoDB query
/* Place model */
module.exports = {
attributes: {
name: {
type: 'string',
required: true
},
// proximity using (slightly) limited native.geoNear
geoProximity: function (req,res) {
console.log('MeetingsController: action=geoProximity ');
console.log(' req.isSocket ', req.isSocket);
console.log(' req.isAjax ', req.isAjax);
console.log(' req.isJson ', req.isJson);
var lat = parseFloat(req.param('lat'));
var lng = parseFloat(req.param('lng'));
var maxDistance = req.param('maxDistance') || 1000;