Skip to content

Instantly share code, notes, and snippets.

Avatar

Jeriel Jan del Prado jerieljan

View GitHub Profile
@jerieljan
jerieljan / SynchronizedRedisBlock.java
Created Jul 28, 2014
The SynchronizedRedisBlock can be used to create a self-isolating block of Redis transactions with a locking mechanism based on the key name provided. Implement by simply instantiating this class and placing all relevant Redis transactions when implementing #perform().
View SynchronizedRedisBlock.java
/*
* SynchronizedRedisBlock v1.0
* v1.0
* June 18, 2014
*
* Copyright 2014, Jeriel Jan del Prado
* 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
@jerieljan
jerieljan / facebook-css.css
Last active Aug 29, 2015
Facebook - No Right Column, Collapsed Left Column
View facebook-css.css
#rightCol {
display:none !important;
}
#leftCol {
width:48px !important;
}
#leftCol:hover {
width:165px !important;
@jerieljan
jerieljan / Job.java
Created Aug 7, 2014
Dealing with long-running, processor-intensive tasks happen, and sometimes, requests for the same tasks get triggered and your system ends up attempting to process the -same- thing multiple times. JobManager is an attempt to resolve that by taking note of each Task<Result> as Jobs, which takes care of assigning future reattempts into existing Jo…
View Job.java
/*
* Job
* v1.0
* June 18, 2014
*
* Copyright 2014, Jeriel Jan del Prado
* 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
@jerieljan
jerieljan / manage-dir.sh
Last active Aug 29, 2015
Manage directories' files using a simple shell script! This script simply relocates files from a base directory to a subdirectory based on its file format.
View manage-dir.sh
#!/bin/bash
# A basic directory management script file.
# Add this to incron via incrontab -e with the IN_CLOSE_WRITE and IN_MOVED_TO flag.
# Usage: manage-dir.sh <file-to-process> <base-directory>
INCOMING="$1"
BASE_DIR="$2"
SUBFOLDER=""
ICON="/usr/share/icons/gnome/32x32/actions/document-save-as.png"
@jerieljan
jerieljan / simple-sync
Last active Aug 29, 2015
A simple shell script that consistently observes a directory and synchronizes its contents when changes are found, using rsync's one-way sync.
View simple-sync
#!/bin/sh
## A simple shell script that consistently observes a directory and synchronizes its contents when changes are found, using rsync's one-way sync.
## Most of the heavy lifting is really done by rsync, so what this script provides is just convenience over cron, notifications (if you have notify-pb) and rsync not being spammed by said cron job through a simple lockfile.
## simple-sync requires rsync, notify-pb (Pushbullet) and preferably run by a scheduler such as cron.
# Core variables
SYNC_HOME='/home/user'
SYNC_SOURCE='user@server.com:/path/to/source/*'
SYNC_DESTINATION="${SYNC_HOME}/path/to/destination/"
View MySQLHandler.cs
// Copyright 2008 - Team Servo
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Data.Sql;
using System.Data.SqlClient;
using MySql.Data.MySqlClient;
View BitmapLruCache.java
package ph.com.voyager.epg.core.model.volley;
import com.android.volley.toolbox.ImageLoader;
import android.graphics.Bitmap;
import android.support.v4.util.LruCache;
/**
* A straightforward implementation of the {@link ImageLoader.ImageCache ImageCache} in LruCache
* provided by Android + Support Library.
@jerieljan
jerieljan / ShowListView.java
Created Jul 11, 2013
A slightly customized list view for displaying shows. Provides handling for touch event greed. This is used so that the main list will not deprive the ViewPager List from horizontal swipe events for changing displayed shows per channel.
View ShowListView.java
package ph.com.voyager.epg.ui;
import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.widget.ListView;
/**
* A slightly customized list view for displaying shows. Provides handling for touch event greed.
* This is used so that the main list will not deprive the ViewPager List from horizontal swipe
@jerieljan
jerieljan / custom_rules.xml
Created Jul 24, 2013
A custom_rules XML file in Ant for performing Robotium tests.
View custom_rules.xml
<?xml version="1.0" encoding="UTF-8"?>
<!-- custom_rules.xml contains a set of added functions for Ant to use. This includes useful macrodefs for
testing a particular test case or package, and you can even define your own that executes them for convenience. -->
<project name="RobotiumMyProject">
<property name="reports.dir" value="reports"/>
<property name="tests.dir" value="com.jerieljan.myproject.tests"/>
<target name="init-props">
@jerieljan
jerieljan / splice-video.sh
Last active Aug 7, 2016
This simple script splices a video file "trimmed.mkv" into multiple videos--defined by X-count and Y-count of screens. Requires ffmpeg.
View splice-video.sh
#!/bin/bash
# This script splices a movie file into multiple parts.
# First parameter for the number of X screens
# Second parameter for the number of Y screens
X_COUNT=$1
Y_COUNT=$2
FILENAME="trimmed.mkv"