Skip to content

Instantly share code, notes, and snippets.

Avatar
💻
on duty

Simon Pham simonpham

💻
on duty
View GitHub Profile
@simonpham
simonpham / hosts
Created Oct 14, 2021
Medium hosts
View hosts
162.159.152.4 medium.com
162.159.152.4 api.medium.com
162.159.152.4 glyph.medium.com
162.159.152.4 miro.medium.com
162.159.152.4 cdn-client.medium.com
162.159.152.4 policy.medium.com
162.159.152.4 cdn-static-1.medium.com
162.159.152.4 cdn-images-1.medium.com
162.159.152.4 cdn-images-2.medium.com
@simonpham
simonpham / 📊 Weekly development breakdown
Last active Oct 29, 2020
📊 Top languages over the last 7 days
View 📊 Weekly development breakdown
Dart 2 hrs 12 mins █████████████▉░░░░░░░ 66.6%
YAML 27 mins ██▊░░░░░░░░░░░░░░░░░░ 13.7%
Other 17 mins █▊░░░░░░░░░░░░░░░░░░░ 8.8%
Groovy 8 mins ▉░░░░░░░░░░░░░░░░░░░░ 4.2%
XML 7 mins ▊░░░░░░░░░░░░░░░░░░░░ 3.8%
View shared_prefs.dart
/// Use SharedPreferences in Flutter effortlessly
/// https://medium.com/@simonpham/use-sharedpreferences-in-flutter-effortlessly-835bba8f7418
// utils/shared_prefs.dart
class SharedPrefs {
static late SharedPreferences _sharedPrefs;
factory SharedPrefs() => SharedPrefs._internal();
SharedPrefs._internal();
View tappable.dart
import 'package:flutter/material.dart';
class Tappable extends StatefulWidget {
final Widget child;
final GestureTapCallback onTap;
final GestureTapCallback onDoubleTap;
final GestureLongPressCallback onLongPress;
final GestureTapDownCallback onTapDown;
final GestureTapCancelCallback onTapCancel;
View gist:c4ccadce377212c123cf4c7aa517dde7
int randomNumber = rand() % (1000 - 0 + 1) + 1000;
int falseCount = -1;
int guessNumber = -1;
while (guessNumber != randomNumber) {
falseCount++;
print("Guess a number: ");
guessNumber = <USER_INPUT_FROM_KEYBOARD>;
View DevetterExample.kt
// Step 1: Set up Devetter on the phone (with WRITE_SECURE_SETTINGS permission approved)
// Step 2: Declare some constants
// <ACTION TYPE>
const val ACTION_PUT_GLOBAL = "com.github.simonpham.devetter.action.PUT_GLOBAL"
const val ACTION_PUT_SECURE = "com.github.simonpham.devetter.action.PUT_SECURE"
const val ACTION_PUT_SYSTEM = "com.github.simonpham.devetter.action.PUT_SYSTEM"
// some constants
const val EXTRA_KEY = "com.github.simonpham.devetter.extra.KEY"
const val EXTRA_VALUE = "com.github.simonpham.devetter.extra.VALUE"
@simonpham
simonpham / gist:348bd69934beff75aa8523e329d9d793
Created Oct 19, 2018
Some media url for testing (HTTP is playable on Android, cannot play HTTPS url)
View gist:348bd69934beff75aa8523e329d9d793
2018-10-19 16:12:39.385 9478-9478/com.onapptv V/onVodPlayClick: https://house-fastly-signed-us-east-1-prod.brightcovecdn.com/media/v1/pmp4/static/clear/5706818955001/a47be557-bb5e-4b40-b3d7-055cfbf13f42/high.mp4?fastly_token=NWJjOWY4MTRfOGVkYzI4Y2I2NmM3NzNlNGI3YjhkZmZjOGU5YzRkNzEyZGE3NjI5ODRjMTljYTkxMjY0MWI2MmFjYWNjNWEwOF8vL2hvdXNlLWZhc3RseS1zaWduZWQtdXMtZWFzdC0xLXByb2QuYnJpZ2h0Y292ZWNkbi5jb20vbWVkaWEvdjEvcG1wNC9zdGF0aWMvY2xlYXIvNTcwNjgxODk1NTAwMS9hNDdiZTU1Ny1iYjVlLTRiNDAtYjNkNy0wNTVjZmJmMTNmNDIvaGlnaC5tcDQ%3D
2018-10-19 16:12:53.130 9478-9478/com.onapptv V/onVodPlayClick: https://house-fastly-signed-us-east-1-prod.brightcovecdn.com/media/v1/pmp4/static/clear/5706818955001/44026df0-4c5d-47b0-bab9-d5b7593b7ecb/high.mp4?fastly_token=NWJjOWY3ZmJfMWQ0NTM0OGUxNTQ5NTliOTc0NjVlMGIwZGUwNTY0ODljMDM5YmYwMDViODgwYjllZDRiMDM4YWU2ZWYzNGM4Nl8vL2hvdXNlLWZhc3RseS1zaWduZWQtdXMtZWFzdC0xLXByb2QuYnJpZ2h0Y292ZWNkbi5jb20vbWVkaWEvdjEvcG1wNC9zdGF0aWMvY2xlYXIvNTcwNjgxODk1NTAwMS80NDAyNmRmMC00YzVkLTQ3YjAtYmFiOS1kNWI3NTkzYjdlY2IvaGlnaC5
View gist:60e8c946871735986a65679470d91a1d
import java.lang.*;
import java.util.*;
public class RotateNumber {
public static long rotateNumber(long number) {
String a = number + "";
a = a.charAt(a.length() - 1) + a.substring(0, a.length() - 1);
return Long.parseLong(a);
}