Skip to content

Instantly share code, notes, and snippets.

@idrisjafer
idrisjafer / rename_obj_keys.js
Created April 9, 2018 12:10
Javascript - Modify Nested Object Keys using Lodash
var _=require('lodash');
//Lodash mixin
_.mixin({
deeply: function (map) {
var deeplyArray = function (obj, fn) {
return obj.map(function(x) {
return _.isPlainObject(x) ? _.deeply(map)(x, fn) : x;
})
}
@idrisjafer
idrisjafer / VolleyWithObservable.java
Created July 28, 2017 07:05
Using RxJava Observables with Volley
RequestFuture<JSONObject> future = RequestFuture.newFuture();
Response.ErrorListener errorListener=future;
Response.Listener<jsonobject> listener = future;
JsonObjectRequest request = new JsonObjectRequest(method, URL, listener, future);
ImmoDroidApplication.getInstance().getVolleyQueue().add(request);
Observable<JSONObject> listObservable = Observable.from(future, Schedulers.io());
@idrisjafer
idrisjafer / convert-UNIX-timestamp.js
Created April 30, 2017 14:07 — forked from kmaida/convert-UNIX-timestamp.js
Convert a UNIX timestamp to user's local time via JavaScript
function convertTimestamp(timestamp) {
var d = new Date(timestamp * 1000), // Convert the passed timestamp to milliseconds
yyyy = d.getFullYear(),
mm = ('0' + (d.getMonth() + 1)).slice(-2), // Months are zero based. Add leading 0.
dd = ('0' + d.getDate()).slice(-2), // Add leading 0.
hh = d.getHours(),
h = hh,
min = ('0' + d.getMinutes()).slice(-2), // Add leading 0.
ampm = 'AM',
time;
@idrisjafer
idrisjafer / gist:3bbaaf0d916c07be4e784230c7b636c0
Created August 16, 2016 14:31 — forked from bryhal/gist:4129042
MYSQL: Generate Calendar Table
DROP TABLE IF EXISTS time_dimension;
CREATE TABLE time_dimension (
id INTEGER PRIMARY KEY, -- year*10000+month*100+day
db_date DATE NOT NULL,
year INTEGER NOT NULL,
month INTEGER NOT NULL, -- 1 to 12
day INTEGER NOT NULL, -- 1 to 31
quarter INTEGER NOT NULL, -- 1 to 4
week INTEGER NOT NULL, -- 1 to 52/53
day_name VARCHAR(9) NOT NULL, -- 'Monday', 'Tuesday'...
@idrisjafer
idrisjafer / README.md
Created June 1, 2016 08:11 — forked from oodavid/README.md
Deploy your site with git

Deploy your site with git

This gist assumes:

  • you have a local git repo
  • with an online remote repository (github / bitbucket etc)
  • and a cloud server (Rackspace cloud / Amazon EC2 etc)
    • your (PHP) scripts are served from /var/www/html/
    • your webpages are executed by apache
  • apache's home directory is /var/www/
@idrisjafer
idrisjafer / JSON_Search
Created April 28, 2015 10:00
JSON Seach by Key or Value or Both
@idrisjafer
idrisjafer / designer.html
Last active August 29, 2015 14:14
designer
<link rel="import" href="../core-icon-button/core-icon-button.html">
<link rel="import" href="../core-toolbar/core-toolbar.html">
<link rel="import" href="../core-header-panel/core-header-panel.html">
<link rel="import" href="../core-drawer-panel/core-drawer-panel.html">
<polymer-element name="my-element">
<template>
<style>
:host {
@idrisjafer
idrisjafer / designer.html
Last active August 29, 2015 14:14
designer
<link rel="import" href="../paper-input/paper-input.html">
<link rel="import" href="../core-icons/core-icons.html">
<link rel="import" href="../core-icons/av-icons.html">
<link rel="import" href="../paper-fab/paper-fab.html">
<link rel="import" href="../topeka-elements/category-icons.html">
<link rel="import" href="../core-icon/core-icon.html">
<link rel="import" href="../core-icon-button/core-icon-button.html">
<link rel="import" href="../core-toolbar/core-toolbar.html">
<link rel="import" href="../core-header-panel/core-header-panel.html">