Skip to content

Instantly share code, notes, and snippets.

View PsyGik's full-sized avatar
🏠
Working from home

Dhanraj Padmashali PsyGik

🏠
Working from home
View GitHub Profile
@PsyGik
PsyGik / random.js
Created January 12, 2018 10:43 — forked from kerimdzhanov/random.js
JavaScript: get a random number from a specific range
/**
* Get a random floating point number between `min` and `max`.
*
* @param {number} min - min number
* @param {number} max - max number
* @return {number} a random floating point number
*/
function getRandomFloat(min, max) {
return Math.random() * (max - min) + min;
}
@PsyGik
PsyGik / message-bus.service.ts
Created December 20, 2017 06:07 — forked from GFoley83/message-bus.service.ts
Angular 2 Message Bus / PubSub ex.
import { Injectable } from "@angular/core";
import { ReplaySubject, Observable } from "rxjs/Rx";
interface Message {
channel: string;
data: any;
}
@Injectable()
export class MessageBus {
@PsyGik
PsyGik / MultiGetSet.js
Created November 19, 2017 06:15 — forked from melanke/MultiGetSet.js
MultiGetSet.JS - Quickly generate getters and setters for multiple attributes
var MultiGetSet = function(opt){
var getType = function(o) {
return ({}).toString.call(o).match(/\s([a-zA-Z]+)/)[1].toLowerCase()
};
if(!opt.public || !opt.private)
return opt.public;
if(opt.handler && opt.handler.init)
@PsyGik
PsyGik / example.component.ts
Created September 10, 2017 13:08 — forked from ckimrie/example.component.ts
Example on how to achieve RxJS observable caching and storage in Angular 2+. Ideal for storing Http requests client side for offline usage.
import { Component, OnInit, OnDestroy } from '@angular/core';
import {Http} from "@angular/http";
import { LocalCacheService } from "./local-cache.service";
@Component({
selector: 'app-example',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss']
})
export class ExampleComponent implements OnInit, OnDestroy {
@PsyGik
PsyGik / gist:b98ed3b1aa237de7949fa7786cece185
Created January 15, 2017 07:34 — forked from tonymtz/gist:d75101d9bdf764c890ef
Uninstall nodejs from OSX Yosemite
# first:
lsbom -f -l -s -pf /var/db/receipts/org.nodejs.pkg.bom | while read f; do sudo rm /usr/local/${f}; done
sudo rm -rf /usr/local/lib/node /usr/local/lib/node_modules /var/db/receipts/org.nodejs.*
# To recap, the best way (I've found) to completely uninstall node + npm is to do the following:
# go to /usr/local/lib and delete any node and node_modules
cd /usr/local/lib
sudo rm -rf node*
@PsyGik
PsyGik / 0 Easy deployment with Grunt and git.md
Created January 27, 2016 06:17 — forked from sarahhenderson/0 Easy deployment with Grunt and git.md
Single command deploy for an Angular/Node web application to Ubuntu EC2 instance

Easy deployment with Grunt and Git

Angular/Node.js web application to Ubuntu EC2 instance

Objective

Deploy entire site to server using a single command grunt deploy

Assumptions

  1. Your web application exists on your local machine in a git repo
  2. You can log into your server via ssh without a password
  3. You are using grunt for your build process
@PsyGik
PsyGik / GoogleAPI.py
Created January 20, 2016 06:32 — forked from SalvaJ/GoogleAPI.py
Example making HTTP request to use Google API without api-client.It works in Python3 (tested ok in 3.3.5)
#!usr/bin/python3
# -*- coding: UTF-8 -*-
"""This module is a sample of the OAuth2 authentication by Python3"""
__version__ = "0.1.0"
__author__ = "shin (shin.hateblo.jp)"
__copyright__ = "(C) 2012 shin"
__email__ = "[email protected]"
__license__ = "Apache License 2.0"
@PsyGik
PsyGik / RecorderService.java
Created October 23, 2015 05:51 — forked from qihnus/RecorderService.java
a minimalist example of Android accessibility service
import android.accessibilityservice.AccessibilityService;
import android.accessibilityservice.AccessibilityServiceInfo;
import android.util.Log;
import android.view.accessibility.AccessibilityEvent;
public class RecorderService extends AccessibilityService {
static final String TAG = "RecorderService";
private String getEventType(AccessibilityEvent event) {
@PsyGik
PsyGik / README.md
Created September 25, 2015 14:07
A click / long press listener for RecyclerViews. Questions? https://twitter.com/lnikkila
@PsyGik
PsyGik / GetActionBarHeight
Last active September 21, 2015 05:31 — forked from laaptu/GetActionBarHeight
Android getting ActionBar Height in dip
public int getActionBarHeight() {
int actionBarHeight = 0;
TypedValue tv = new TypedValue();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
if (getTheme().resolveAttribute(android.R.attr.actionBarSize, tv,
true))
actionBarHeight = TypedValue.complexToDimensionPixelSize(
tv.data, getResources().getDisplayMetrics());
} else {
actionBarHeight = TypedValue.complexToDimensionPixelSize(tv.data,