Skip to content

Instantly share code, notes, and snippets.

View Shilo's full-sized avatar

Shilo Shilo

View GitHub Profile
@ftvs
ftvs / PhonecallReceiver.java
Last active October 11, 2023 10:05
Detecting an incoming call coming to an Android device. Remember to set the appropriate permissions in AndroidManifest.xml as suggested in the Stackoverflow link. Usage example in comments. Source: Gabe Sechan http://stackoverflow.com/a/15564021/264619 Explanation: http://gabesechansoftware.com/is-the-phone-ringing/#more-8
package com.gabesechan.android.reusable.receivers;
import java.util.Date;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.telephony.TelephonyManager;
public abstract class PhonecallReceiver extends BroadcastReceiver {
@endel
endel / number-pad-zero.js
Last active August 1, 2023 11:54
Simplest way for leading zero padding in JavaScript
Number.prototype.pad = function(size) {
var s = String(this);
while (s.length < (size || 2)) {s = "0" + s;}
return s;
}
(1).pad(3) // => "001"
(10).pad(3) // => "010"
(100).pad(3) // => "100"
@samuelbeek
samuelbeek / Platform.swift
Created November 24, 2015 12:23
Detect if Simulator is used in Swift
struct Platform
{
static let isSimulator: Bool = {
var isSim = false
#if arch(i386) || arch(x86_64)
isSim = true
#endif
return isSim
}()
}
@lopspower
lopspower / README.md
Last active May 23, 2024 07:29
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

@Shilo
Shilo / Perfect_Convo_With_Boss.txt
Created April 14, 2016 09:32
Perfect Conversation with Mr. Boss, AKA Benjamin.
Shilo: Benjamin! Benjamin! Benjamin! Benjamin! Benjamin! Benjamin! Boss! Boss! Boss! Leader! Leader! Leader! Master! Master! Master! Ben!
Ben! Ben! Ben! Benni! Benni! Benni! Benni! Benji! Benji! Benj! Benj! Benj!
Benjamin: What!?
Shilo: Hi! (Giggling and running out of the room)
https://www.youtube.com/watch?v=aOLxQGLJouI
@Shilo
Shilo / defaults.sh
Last active June 12, 2016 17:18
OS X Useful Terminal Commands
//Disable app nap system-wide (Requires Restart)
defaults write NSGlobalDomain NSAppSleepDisabled -bool YES
//Finder show hidden files
defaults write com.apple.finder AppleShowAllFiles YES; killall Finder
//Desktop hide icons
defaults write com.apple.finder CreateDesktop false; killall Finder
//TextEdit open new document by default (Requires restart of TextEdit)
@StickyCube
StickyCube / index.html
Created June 27, 2016 22:52
Electron click through transparency example
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Test App</title>
</head>
<style>
html, body {
height: 100%;
@mlynch
mlynch / cordova-plugin-guide.md
Last active February 3, 2023 00:21
Cordova Plugin Developer Guide

Cordova Plugin Development Guide (iOS and Android)

Version: 0.0.1 updated 7/1/2016

Cordova Plugins are the magic that enable our mobile web app content to access the full power of Native SDKs underneath, but through clean JavaScript APIs that work the same across all platforms we target.

Building Cordova plugins is scary for many Cordova and Ionic developers, but it doesn't have to be. This simple guide walks through the what, when, why, and how of Cordova plugin development for iOS and Android.

Introduction

@Shilo
Shilo / filename_append_2x.sh
Created July 16, 2016 10:26
Terminal command to append "@2x" to file names inside current directory.
for file in *; do mv "$file" "${file%.*}@2x.${file##*.}"; done
@Shilo
Shilo / NavigationController.m
Last active July 16, 2016 12:57
iOS - Dynamically load navigation bar title image with interpolation. How to use: Set navigation title as "{image_name_here}"
#define NAV_PORTRAIT_HEIGHT 44
- (void)viewDidLoad {
[super viewDidLoad];
[self loadNavigationBarTitleImage];
}
- (void)loadNavigationBarTitleImage {
NSString *title = self.navigationItem.title;
NSInteger prefixLength = NAV_TITLE_IMAGE_PREFIX.length;