Skip to content

Instantly share code, notes, and snippets.

View bhrott's full-sized avatar
⚔️
killing zombies

Ben-Hur Santos Ott bhrott

⚔️
killing zombies
View GitHub Profile
@bhrott
bhrott / AndroidCheckNotificationIsEnabled.java
Created November 16, 2016 11:54
React Native : Android : Check notification is enabled
@ReactMethod
public void areNotificationsEnabled(Promise promise) {
try {
Boolean areEnabled = NotificationManagerCompat.from(getReactApplicationContext()).areNotificationsEnabled();
promise.resolve(areEnabled);
}catch (Exception e) {
promise.reject(e);
}
}
@bhrott
bhrott / osx-disabling-gpg-for-commits.sh
Created February 11, 2017 22:49
OSX: disabling gpg for commits
!#/bin/bash
git config --global commit.gpgsign false
@bhrott
bhrott / GIF-Screencast-OSX.md
Created February 14, 2017 00:40 — forked from dergachev/GIF-Screencast-OSX.md
OS X Screencast to animated GIF

OS X Screencast to animated GIF

This gist shows how to create a GIF screencast using only free OS X tools: QuickTime, ffmpeg, and gifsicle.

Screencapture GIF

Instructions

To capture the video (filesize: 19MB), using the free "QuickTime Player" application:

@bhrott
bhrott / cluster_node.js
Last active December 1, 2017 13:06
Cluster Node
var http = require('http');
var cluster = require('cluster');
if (cluster.isMaster) {
var cpuCount = require('os').cpus().length;
for (var i = 0; i < cpuCount; i += 1) {
cluster.fork();
}
}
@bhrott
bhrott / FuckingSubstringSwift3.md
Last active December 30, 2018 00:34
Fucking substring Swift 3

1 - Create a extensions for String with a new, wonderfull, superpower method called crop:

extension String {
    func crop(from: Int, length: Int) -> String! {
        let startIndex = self.index(self.startIndex, offsetBy: from)
        
        var result = self.substring(from: startIndex)
        
        let endIndex = result.index(result.startIndex, offsetBy: length)
 result = result.substring(to: endIndex)
@bhrott
bhrott / UIColorExtension.md
Created March 1, 2017 22:16
Swift 3: Hex UIColor

Extension:

import Foundation
import UIKit

extension UIColor {
    convenience init(hexString: String) {
        let hex = hexString.trimmingCharacters(in: CharacterSet.alphanumerics.inverted)
        var int = UInt32()
 Scanner(string: hex).scanHexInt32(&amp;int)
@bhrott
bhrott / readingPlist.swift
Created March 31, 2017 16:36
Swift :: Read PList
func read(name: String) -> [String: Any] {
if let fileUrl = Bundle.main.url(forResource: name, withExtension: "plist"),
let data = try? Data(contentsOf: fileUrl) {
if let result = try? PropertyListSerialization.propertyList(from: data, options: [], format: nil) as? [String: Any] {
return result!
}
}
return [:]
}
@bhrott
bhrott / userDefaultService.swift
Created March 31, 2017 16:37
Swift :: Service for UserDefaults
import Foundation
class UserDefaultsService {
static private var _instance: UserDefaultsService! = nil
static var sharedInstance: UserDefaultsService {
get {
if UserDefaultsService._instance == nil {
UserDefaultsService._instance = UserDefaultsService()
}
@bhrott
bhrott / notificationService.swift
Created March 31, 2017 16:39
Swift :: Service for Notifications
import Foundation
class NotificationService {
static private var _instance: NotificationService! = nil
static var sharedInstance: NotificationService {
get {
if NotificationService._instance == nil {
NotificationService._instance = NotificationService()
@bhrott
bhrott / css_card_size.css
Created May 27, 2017 18:12
Css Card Size
.card {
width: 230.551181102px;
height: 325.039370079px;
border: 5px solid #8B7355;
overflow: hidden;
float: left;
position: relative;
margin: 10px 10px;
background-image: url(img/parchment-bg.jpg);