Skip to content

Instantly share code, notes, and snippets.

View NelzkieCoder's full-sized avatar

Nelzkie NelzkieCoder

View GitHub Profile
@raveesh-me
raveesh-me / main.dart
Created July 7, 2018 00:22
An inherited callback pattern to change InheritedWidget state in flutter
import 'package:flutter/material.dart';
import 'package:flutter_login_manager/splash_screen.dart';
import 'package:flutter_login_manager/model/login_info.dart';
import 'package:flutter_login_manager/model/login.dart' as loginManager;
import 'package:flutter_login_manager/home_screen.dart';
void main() => runApp(MyApp());
class MyApp extends StatefulWidget {
@override
@zcaceres
zcaceres / Revealing-Module-Pattern.md
Last active June 18, 2024 00:44
Using the Revealing Module Pattern in Javascript

The Revealing Module Pattern in Javascript

Zach Caceres

Javascript does not have the typical 'private' and 'public' specifiers of more traditional object oriented languages like C# or Java. However, you can achieve the same effect through the clever application of Javascript's function-level scoping. The Revealing Module pattern is a design pattern for Javascript applications that elegantly solves this problem.

The central principle of the Revealing Module pattern is that all functionality and variables should be hidden unless deliberately exposed.

Let's imagine we have a music application where a musicPlayer.js file handles much of our user's experience. We need to access some methods, but shouldn't be able to mess with other methods or variables.

Using Function Scope to Create Public and Private Methods

@mikemimik
mikemimik / main.dart
Last active August 3, 2022 04:21
Flutter: Custom theme data
import 'package:flutter/material.dart';
import 'theme.dart' as Theme;
void main() {
runApp(
new MaterialApp(
title: 'CompanyApp',
color: Theme.CompanyColors.blue[500],
theme: Theme.CompanyThemeData,
home: new Scaffold(
@vxhviet
vxhviet / viewPager_part2.md
Last active December 21, 2020 03:53
View Pager without fragment

Source: BigNerdRanch

Answer: demo simple ViewPager without using Fragment

TutorialActivity.java:

public class TutorialActivity extends AppCompatActivity {
    private static final int NUMBER_OF_PAGE = 5;
    private static final int DELAY_TIME = 2000; //time in milliseconds to automatically scroll to a new page
@lopspower
lopspower / README.md
Last active July 20, 2024 20:26
Hexadecimal color code for transparency

Hexadecimal color code for transparency

Twitter

How to set transparency with hex value ?

For example, you want to set 40% alpha transparence to #000000 (black color), you need to add 66 like this #66000000.

Download This sample on Google Play Store

@oanhnn
oanhnn / using-multiple-github-accounts-with-ssh-keys.md
Last active July 22, 2024 13:33
Using multiple github accounts with ssh keys

Problem

I have two Github accounts: oanhnn (personal) and superman (for work). I want to use both accounts on same computer (without typing password everytime, when doing git push or pull).

Solution

Use ssh keys and define host aliases in ssh config file (each alias for an account).

How to?

  1. Generate ssh key pairs for accounts and add them to GitHub accounts.
@Phlow
Phlow / jekyll-sorted-category-for-loop-alphabetical-date.liquid
Last active March 12, 2022 14:18
Jekyll (Liquid) for loop to sort posts by category in alphabetical or date-based or similiar order.
{% comment %}
#
# Change date order by adding '| reversed'
# To sort by title or other variables use {% assign sorted_posts = category[1] | sort: 'title' %}
#
{% endcomment %}
{% assign sorted_cats = site.categories | sort %}
{% for category in sorted_cats %}
{% assign sorted_posts = category[1] | reverse %}
<h2 id="{{category[0] | uri_escape | downcase }}">{{category[0] | capitalize}}</H2>
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
TableLayout table = new TableLayout(this);
table.setStretchAllColumns(true);
table.setShrinkAllColumns(true);
TableRow rowTitle = new TableRow(this);
@alphamu
alphamu / AA Transition App theme between light and dark themes
Last active September 9, 2022 21:59
Example of how to change themes at runtime with a smooth animation. In this example, we just switch between a light and a dark theme. The activity animation is defined in the theme and as such will be default on all activities with the set theme. [Demo Video here](http://youtu.be/Ps0phswbHls).
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ListView;
public class TransitionThemeActivity extends AppCompatActivity implements View.OnClickListener {
Unless specified otherwise, all of the below tinting applies to both Lollipop and pre-Lollipop using AppCompat v21.
To use the support version of these attributes, remove the android namespace.
For instance, "android:colorControlNormal" becomes "colorControlNormal".
These attributes will be propagated to their corresponding attributes within the android namespace
for devices running Lollipop. Any exceptions to this will be noted by including the "android:" prefix.
All Clickable Views:
-----------