Skip to content

Instantly share code, notes, and snippets.

/*
* Copyright (C) 2012 The Android Open Source Project
*
* 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
*
* Unless required by applicable law or agreed to in writing, software
@menuka94
menuka94 / data-structure.js
Created February 14, 2017 16:47 — forked from sararob/data-structure.js
Role-based security in Firebase
/*
This example shows how you can use your data structure as a basis for
your Firebase security rules to implement role-based security. We store
each user by their Twitter uid, and use the following simplistic approach
for user roles:
0 - GUEST
10 - USER
20 - MODERATOR
@menuka94
menuka94 / kill-processes.sh
Last active February 18, 2017 11:53
Linux (Ubuntu) Commands
sudo kill $(sudo lsof -t -i:8000) # kill process on port 8000
@menuka94
menuka94 / basic-usage.java
Created March 3, 2017 06:17
Android - Folding Cell UI
// get our folding cell
final FoldingCell foldingCell = (FoldingCell) findViewById(R.id.folding_cell);
// set custom parameters
foldingCell.initialize(1000, Color.DKGRAY, 2);
// or with camera height parameter
foldingCell.initialize(cameraHeight, animationDuration, backSideColor, additionalFlipCounts);
foldingCell.initialize(1000, Color.DKGRAY, 0);
@menuka94
menuka94 / child-component.html
Created April 11, 2017 03:46
Angular 2 Inputs and Outputs
<h2>Child Component</h2>
<label>Enter value</label>
<input type="text" #childText (keyup)="onChange(childText.value)">
<p>Value from Parent Component: {{parentData}}</p>
import {Injectable} from '@angular/core';
import {FirebaseAuth, AngularFire} from "angularfire2";
import {Subject, Observable, BehaviorSubject} from "rxjs";
import {AuthInfo} from "./auth-info";
@Injectable()
export class AuthService {
static UNKNOWN_USER = new AuthInfo(null);
authInfo$: BehaviorSubject<AuthInfo> = new BehaviorSubject<AuthInfo>(AuthService.UNKNOWN_USER);
@menuka94
menuka94 / rest-consumer.go
Created July 16, 2017 17:27
Go: REST Server and Client
package main
import (
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
)
type Fruits map[string]int
@menuka94
menuka94 / main.go
Created August 1, 2017 04:58 — forked from manishtpatel/main.go
GoLang Encrypt string to base64 and vice versa using AES encryption.
package main
import (
"crypto/aes"
"crypto/cipher"
"crypto/rand"
"encoding/base64"
"fmt"
"io"
)
@menuka94
menuka94 / one.go
Last active August 8, 2017 08:23
Go - HTTP Requests
// https://stackoverflow.com/questions/40006631/sending-post-request-in-golang-with-header
package main
import (
"fmt"
"net/http"
"crypto/tls"
)
func main() {
@menuka94
menuka94 / goth
Created August 31, 2017 09:31 — forked from ammario/goth
golang test coverage html
#!/bin/bash
go test -coverprofile=coverage.out
go tool cover -html=coverage.out