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 / hashtag
Last active August 15, 2016 10:51
[
{
"category": "#love",
"tags": [
"Love",
"InstaLove",
"MyLove",
"Lovers",
"LoveLife",
"LoveStory",
@PsyGik
PsyGik / PrefixInputFilter
Created August 13, 2016 13:01
Prefix edittext with the given prefix. User will not be able to remove it by backspacing. Useful when prefixing #Hashtags
final String prefix = "#";
InputFilter hashWatcher = new InputFilter() {
@Override
public CharSequence filter(final CharSequence source, final int start,
final int end, final Spanned dest, final int dstart, final int dend) {
final int newStart = Math.max(prefix.length(), dstart);
final int newEnd = Math.max(prefix.length(), dend);
if (newStart != dstart || newEnd != dend) {
final SpannableStringBuilder builder = new SpannableStringBuilder(dest);
builder.replace(newStart, newEnd, source);
{
"#000000": "Black",
"#000080": "Navy Blue",
"#0000C8": "Dark Blue",
"#0000FF": "Blue",
"#000741": "Stratos",
"#001B1C": "Swamp",
"#002387": "Resolution Blue",
"#002900": "Deep Fir",
"#002E20": "Burnham",
@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 / build.gradle
Created February 10, 2017 05:43
Gradle config to automatically add version info to strings.xml
def versionMajor = 1
def versionMinor = 1
def versionPatch = 2
def versionNameSuffix = ".debug"
android {
defaultConfig {
versionCode versionMajor * 10000 + versionMinor * 100 + versionPatch
versionName "${versionMajor}.${versionMinor}.${versionPatch}"
resValue "string", "app_version",
@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 / 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 / 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 / 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;
}
import { TestBed, async, inject } from '@angular/core/testing';
import { HttpClientModule, HttpRequest, HttpParams } from '@angular/common/http';
import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing';
import { HttpClientFeatureService } from './http-client-feature.service';
describe(`HttpClientFeatureService`, () => {
beforeEach(() => {
TestBed.configureTestingModule({
imports: [