Skip to content

Instantly share code, notes, and snippets.

View ryancheung's full-sized avatar
🌝

Ryan Cheung ryancheung

🌝
  • Earth
View GitHub Profile
@ryancheung
ryancheung / MySQL_5-7_macOS.md
Created December 28, 2019 10:57 — forked from robhrt7/MySQL_5-7_macOS.md
Install MySQL 5.7 on macOS using Homebrew

This is a fork of original gist https://gist.github.com/nrollr/3f57fc15ded7dddddcc4e82fe137b58e, with slight changes on pointing to 5.7 version branch, instead of 8 (latest default of MySQL in Hombrew).

Install MySQL 5.7 on macOS

This procedure explains how to install MySQL using Homebrew on macOS (Sierra 10.12 and up)

Install Homebrew

  • Installing Homebrew is effortless, open Terminal and enter :
    $ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
  • Note: Homebrew will download and install Command Line Tools for Xcode 8.0 as part of the installation process.
@ryancheung
ryancheung / remap-capslock-to-control-win10.md
Created October 22, 2019 08:19 — forked from joshschmelzle/remap-capslock-to-control-win10.md
Remap Caps Lock to Control on Windows 10

Create a new binary value in HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout named Scancode Map

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout]
"Scancode Map"=hex:00,00,00,00,00,00,00,00,02,00,00,00,1d,00,3a,00,00,00,00,00

or use PowerShell (run as Admin)

// g++ -Wall -O -o sdlgpu-test $(pkg-config SDL2_gpu --cflags) $(sdl2-config --cflags) sdlgpu-test.cc $(pkg-config SDL2_gpu --libs) $(sdl2-config --libs)
#include <SDL_gpu.h>
int main(int argc, char* argv[])
{
GPU_SetDebugLevel(GPU_DEBUG_LEVEL_MAX);
GPU_Target* screen = GPU_Init(400, 300, GPU_DEFAULT_INIT_FLAGS);
if (!screen)
@ryancheung
ryancheung / test.c
Created December 23, 2018 21:46 — forked from incinirate/test.c
Demonstration of slowdown when using BlitRect
#include "SDL.h"
#include "SDL_gpu.h"
#include <stdio.h>
#define WIDTH 280
#define HEIGHT 160
#define SCALE 3
bool running = true;
bool doScale = true;
@ryancheung
ryancheung / hmac-sha1.rb
Created March 27, 2017 09:44 — forked from kovacshuni/hmac-sha1.rb
Ruby HMAC-SHA1 digest creation
require 'base64'
require 'cgi'
require 'openssl'
base = 'POST&https%3A%2F%2Fapi.twitter.com%2F1%2Fstatuses%2Fupdate.json&include_entities%3Dtrue%26oauth_consumer_key%3Dxvz1evFS4wEEPTGEFPHBog%26oauth_nonce%3DkYjzVBB8Y0ZFabxSWbWovY3uYSQ2pTgmZeNu2VS4cg%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1318622958%26oauth_token%3D370773112-GmHxMAgYyLbNEtIKZeRNFsMKPR9EyMZeS9weJAEb%26oauth_version%3D1.0%26status%3DHello%2520Ladies%2520%252B%2520Gentlemen%252C%2520a%2520signed%2520OAuth%2520request%2521'
key = 'kAcSOqF21Fu85e7zjz7ZN2U4ZRhfV3WpwPAoE3Z7kBw&LswwdoUaIvS8ltyTt5jkRh4J50vUPVVHtR2YPi5kE'
puts CGI.escape(Base64.encode64("#{OpenSSL::HMAC.digest('sha1', key, base)}\n"))
@ryancheung
ryancheung / yardoc_cheatsheet.md
Created January 11, 2017 05:34 — forked from chetan/yardoc_cheatsheet.md
YARD cheatsheet

YARD CHEATSHEET http://yardoc.org

cribbed from http://pastebin.com/xgzeAmBn

Templates to remind you of the options and formatting for the different types of objects you might want to document using YARD.

Modules

Namespace for classes and modules that handle serving documentation over HTTP

@ryancheung
ryancheung / randutils.hpp
Created July 26, 2016 04:48 — forked from imneme/randutils.hpp
Addresses common issues with C++11 random number generation; makes good seeding easier, and makes using RNGs easy while retaining all the power.
/*
* Random-Number Utilities (randutil)
* Addresses common issues with C++11 random number generation.
* Makes good seeding easier, and makes using RNGs easy while retaining
* all the power.
*
* The MIT License (MIT)
*
* Copyright (c) 2015 Melissa E. O'Neill
*
#! /bin/bash
### BEGIN INIT INFO
# Provides: redis-server
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Should-Start: $local_fs
# Should-Stop: $local_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: redis-server - Persistent key-value db
# replace file basename with a UUID when uploaded
# e.g.: avatar.jpg becomes 41bf830f-80cf-4efe-ad90-3b29bc6708b5.jpg
# but don't regenerate a UUID each time file url is accessed
class User < ActiveRecord::Base
has_attached_file :avatar, path: ":basename.:extension"
before_validation { set_avatar_file_name }
def set_avatar_file_name
# replace any NEW filename with a UUID
# rubocop config files for small Rails4/Ruby2 project
# blog post: http://joanswork.com/rubocop-rails-getting-started/
# .rubocop.yml
AllCops:
Include:
- Rakefile
- config.ru
Exclude: