Skip to content

Instantly share code, notes, and snippets.

@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.sh
Last active March 31, 2018 10:41
Python Virtual Environments
# 'env' => name of the environment
virtualenv tempEnv
# or, for python3
virtualenv -p python3 tempEnv
# activate the created enviroment
source tempEnv/bin/activate
# execute commands on the activated environment
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 / 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>
@menuka94
menuka94 / MainActivity.java
Created March 3, 2017 09:01
Android Firebase Authentication
// Firebase instance variables
private FirebaseAuth mFirebaseAuth;
private FirebaseUser mFirebaseUser;
private String mUsername;
private String mPhotoUrl;
@Override
protected void onCreate(Bundle savedInstanceState){
// Initialize Firebase Auth
mFirebaseAuth = FirebaseAuth.getInstance();
@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 / fix-nautilus.sh
Last active August 18, 2018 18:01 — forked from jiromm/gist:ce628934a90433c56252
Linux Commands
# Find the process IDs
ps awx | grep nautilus
# Then kill it
sudo kill -TERM <id>
@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
/*
* 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 / MainActivity.java
Created February 11, 2017 13:22
Android Custom List View with Custom Adapter
package com.example.menuka.adaptertest;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.ListView;
import java.util.ArrayList;
import java.util.List;
public class MainActivity extends AppCompatActivity {