Skip to content

Instantly share code, notes, and snippets.

View sirvon's full-sized avatar

SirVon Thomas sirvon

  • XNA Inc.
  • California, USA
View GitHub Profile
@android10
android10 / AndroidApplication.java
Created July 20, 2016 09:56
Android: how to know if your app is completely hidden
public class AndroidApplication extends MultiDexApplication {
public static final String TAG = AndroidApplication.class.getSimpleName();
@Override
public void onCreate() {
super.onCreate();
registerComponentCallbacks(new ComponentCallback());
}
private class ComponentCallback implements ComponentCallbacks2 {
@lurch
lurch / pizero_usb_internet.sh
Last active November 1, 2022 16:59
Script to automatically provide internet access to a PiZero connected to a Linux host over a USB-network (only tested on Ubuntu 14.04)
#!/bin/bash
# Automatically setup routing and DNS for a PiZero connected over a USB-network
# NOTE: Before running this script for the first time, you need to run the
# following two commands on your Linux PC
# sudo sysctl -w net.ipv4.ip_forward=1
# sudo iptables -t nat -A POSTROUTING -s 169.254.0.0/16 -o eth0 -j MASQUERADE
# (replace eth0 in the second command with your internet-facing network device,
# e.g. wlan0 on a laptop)
# The Avahi-discovered hostname
@robertofrontado
robertofrontado / RxKeyboard
Created May 17, 2016 17:26
Useful Rx tool to works with the Keyboard states in iOS
//
// RxKeyboard.swift
// RxTools
//
// Created by Roberto Frontado on 5/16/16.
// Copyright © 2016 Roberto Frontado. All rights reserved.
//
import RxSwift
@anthonya1999
anthonya1999 / UIDevice+Extensions.h
Last active June 15, 2018 06:54
Just some cool extensions that can tell you some more stuff about a device (all work on latest iOS version)
#import <UIKit/UIKit.h>
#include <dlfcn.h>
static const CFStringRef kMGDieID = CFSTR("DieId");
typedef NS_ENUM(NSInteger, BKSInterfaceOrientation) {
BKSInterfaceOrientationPortrait = 1,
BKSInterfaceOrientationPortraitUpsideDown = 2,
BKSInterfaceOrientationLandscapeRight = 3,
BKSInterfaceOrientationLandscapeLeft = 4
@carolineschnapp
carolineschnapp / multiple images for a variant.md
Created March 31, 2016 01:23
"Grouped variant images". Solution good for all themes, no change to markup required.

What to do

  1. Use the alt text to associate the additional images - besides the variant image - to the option value. Example: say you have 3 images that show the Blue variants, then a) associate the first image as variant image to all Blue variants, and b) set the alt text of the 2 additional images to 'Blue'.
  2. Copy+paste the code found in the product.liquid snippet below at the bottom of your product.liquid template.

How that works, essentially

Only the images associated to the currently selected variant are shown. Other images are hidden.

What to expect, the specifics

@robertofrontado
robertofrontado / RxMoyaProvider.swift
Created March 10, 2016 15:41
Returning Observable from request on a background thread
import Foundation
import RxSwift
/// Subclass of MoyaProvider that returns Observable instances when requests are made. Much better than using completion closures.
public class RxMoyaProvider<Target where Target: TargetType>: MoyaProvider<Target> {
/// Initializes a reactive provider.
override public init(endpointClosure: EndpointClosure = MoyaProvider.DefaultEndpointMapping,
requestClosure: RequestClosure = MoyaProvider.DefaultRequestMapping,
stubClosure: StubClosure = MoyaProvider.NeverStub,
manager: Manager = RxMoyaProvider<Target>.DefaultAlamofireManager(),
@AliSoftware
AliSoftware / Coordinator.swift
Last active July 10, 2022 14:32
Coordinators & StateMachine - Concept
struct Coordinator {
let window: UIWindow
let navCtrl: UINavigationController?
func start() {
presentWelcomeScreen()
}
private func presentWelcomeScreen() {
let vc = WelcomeScreenViewController() // Instanciate from code, XIB, Storyboard, whatever your jam is

Android Studio's Android SDK Location

/Users/[Username]/Library/Android/sdk

Don't have a Homebrew managed NPM

Homebrew is a handy tool for installing applications on OS X that aren't available in the app store. The downside is having a package manager handle another package manager with different opinions on architecture gets hairy, and your NPM installation will have reliability issues in the future if you install Node with Homebrew. However if you're on Windows you shouldn't have an issue using Chocolatey.

The most robust way to install Node is by installing it under NVM (Node Version Manager). If you already have NVM, or have a version of Node 4+ installed from other means (not Homebrew), you can skip to Step 2.

Uninstall Previous Node Installation

You can uninstall an existing version of node by following the advice in this gist, supplied for brevity here:

@idibidiart
idibidiart / GraphQL-Architecture.md
Last active September 16, 2023 18:36
Building an Agile, Maintainable Architecture with GraphQL

Building a Maintainable, Agile Architecture for Realtime, Transactional Apps

A maintainable application architecture requires that the UI only contain the rendering logic and execute queries and mutations against the underlying data model on the server. A maintainable architecture must not contain any logic for composing "app state" on the client as that would necessarily embed business logic in the client. App state should be persisted to the database and the client projection of it should be composed in the mid tier, and refreshed as mutations occur on the server (and after network interruption) for a highly interactive, realtime UX.

With GraphQL we are able to define an easy-to-change application-level data schema on the server that captures the types and relationships in our data, and wiring it to data sources via resolvers that leverage our db's own query language (or data-oriented, uniform service APIs) to resolve client-specified "queries" and "mutations" against the schema.

We use GraphQL to dyn

@FGoessler
FGoessler / ServiceLocator.swift
Created January 24, 2016 20:45
A very lightweight ServiceLocator implementation including a module mechanism written in Swift.
import Foundation
public protocol ServiceLocatorModul {
func registerServices(serviceLocator: ServiceLocator)
}
public class ServiceLocator {
private var registry = [ObjectIdentifier:Any]()
public static var sharedLocator = ServiceLocator()