Skip to content

Instantly share code, notes, and snippets.

View shiki's full-sized avatar

Jayson Basañes shiki

View GitHub Profile
@AliSoftware
AliSoftware / git-groom
Last active December 7, 2021 15:46
Sync git working copies' trunk and develop branches and prune local and remote deleted/orphan branches
#!/bin/bash -euo pipefail
#
# Author: O.Halligon
# Jan 2021
#
# Help
if [ "${1:-}" == "-h" -o "${1:-}" == "--help" ]; then
BASENAME=${0##*/}
@hypest
hypest / compile-aztec-directly.patch
Created June 6, 2018 11:31
wpandroid patch to compile Aztec directly
diff --git a/build.gradle b/build.gradle
index 29290bc..fb8d9b4 100644
--- a/build.gradle
+++ b/build.gradle
@@ -1,6 +1,19 @@
buildscript {
- ext.kotlin_version = '1.2.31'
- ext.arch_components_version = '1.1.1'
+ ext {
+ gradlePluginVersion = '3.0.1'
@ndbroadbent
ndbroadbent / rn-cli.config.js
Created May 26, 2017 18:46
React Native CLI config
const path = require('path')
const sharedBlacklist = []
const platformBlacklists = {
ios: [
'.web.js',
'.macos.js',
/node_modules\/react-native-web\/.*/,
/node_modules\/react-native-windows\/.*/,
@gnumilanix
gnumilanix / KeyboardDismissingRecyclerView.java
Created February 28, 2017 04:57
Implementation of RecyclerView that will dismiss keyboard when scrolling.
package com.lalamove.core.view;
import android.content.Context;
import android.support.annotation.Nullable;
import android.support.v7.widget.RecyclerView;
import android.util.AttributeSet;
import android.view.inputmethod.InputMethodManager;
/**
* Implementation of {@link RecyclerView} that will dismiss keyboard when scrolling.
@joepie91
joepie91 / random.md
Last active May 11, 2024 10:28
Secure random values (in Node.js)

Not all random values are created equal - for security-related code, you need a specific kind of random value.

A summary of this article, if you don't want to read the entire thing:

  • Don't use Math.random(). There are extremely few cases where Math.random() is the right answer. Don't use it, unless you've read this entire article, and determined that it's necessary for your case.
  • Don't use crypto.getRandomBytes directly. While it's a CSPRNG, it's easy to bias the result when 'transforming' it, such that the output becomes more predictable.
  • If you want to generate random tokens or API keys: Use uuid, specifically the uuid.v4() method. Avoid node-uuid - it's not the same package, and doesn't produce reliably secure random values.
  • If you want to generate random numbers in a range: Use random-number-csprng.

You should seriously consider reading the entire article, though - it's

@grantland
grantland / post.md
Last active February 9, 2023 05:09
RecyclerView item onClick

RecyclerView item onClick

RecyclerView does not have an OnItemClickListener like it's predecessor, ListView. However, detecting item clicks is pretty simple.

Set an OnClickListener in your ViewHolder creation:

private class MyAdapter extends RecyclerView.Adapter<MyAdapter.ViewHolder>  {

    public static class ViewHolder extends RecyclerView.ViewHolder
@ipedrazas
ipedrazas / gist:6d6c31144636d586dcc3
Last active July 10, 2023 16:24
Nginx ssl config

The process starts by creating the CSR and the private key:

openssl req -nodes -newkey rsa:2048 -nodes -keyout dotmarks.net.key -out dotmarks.net.csr -subj "/C=GB/ST=London/L=London/O=dotmarks/OU=IT/CN=dotmarks.net"

Generates

  • dotmarks.net.key
  • dotmarks.net.csr
@MrZoidberg
MrZoidberg / mapbox-background.m
Last active August 29, 2015 13:56
Mapbox background rendering HOW-TO
//First of all you need to modify your Mapbox SDK with the this commit:
//https://github.com/MrZoidberg/mapbox-ios-sdk/commit/2865d642f163b15f939a906337de4f53bd17a7b6
//Otherwise you will have random crashes during background rendering of maps
//We need semaphore to limit the number of concurrent threads
//Place it one per view
dispatch_semaphore_t _concurrencyLimitingSemaphore = dispatch_semaphore_create(3);
//Also we need cache to store snapshots of the map
NSCache *_imageCache = [NSCache new];
@bhaberer
bhaberer / submodule_strategy.rb
Last active January 29, 2019 20:13 — forked from stevenscg/submodule_strategy.rb
Capistrano 3.1.x Strategy to deploy git projects with submodules.
# Usage:
# 1. Drop this file into lib/capistrano/submodule_strategy.rb
# 2. Add the following to your Capfile:
# require 'capistrano/git'
# require './lib/capistrano/submodule_strategy'
# 3. Add the following to your config/deploy.rb
# set :git_strategy, SubmoduleStrategy
module SubmoduleStrategy
# do all the things a normal capistrano git session would do
@rsaunders100
rsaunders100 / gist:8436798
Created January 15, 2014 14:03
To prevent application logic from interfering with unit tests.
static BOOL isRunningTests(void) __attribute__((const));
- (BOOL)application:(UIApplication *)application
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
if (isRunningTests()) {
return YES;
}
//