Skip to content

Instantly share code, notes, and snippets.

View ninjachen's full-sized avatar
🥝
Food makes me happy

Ninja Chen ninjachen

🥝
Food makes me happy
  • Shanghai, China
View GitHub Profile
PokemonProject-parent

How to set up stress-free SSL on an OS X development machine

One of the best ways to reduce complexity (read: stress) in web development is to minimize the differences between your development and production environments. After being frustrated by attempts to unify the approach to SSL on my local machine and in production, I searched for a workflow that would make the protocol invisible to me between all environments.

Most workflows make the following compromises:

  • Use HTTPS in production but HTTP locally. This is annoying because it makes the environments inconsistent, and the protocol choices leak up into the stack. For example, your web application needs to understand the underlying protocol when using the secure flag for cookies. If you don't get this right, your HTTP development server won't be able to read the cookies it writes, or worse, your HTTPS production server could pass sensitive cookies over an insecure connection.

  • Use production SSL certificates locally. This is annoying

@ninjachen
ninjachen / gist:d7cabce1acfe10e00c7d
Created February 15, 2015 09:43
android wearable test
package com.geexFinance.GeexSaler.getui;
import android.app.Notification;
import android.app.PendingIntent;
import android.app.TaskStackBuilder;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
package com.npi.blureffect;
/**
* Created by ninja on 3/4/15.
*/
public class NinjaCandy {
public int candy(int[] ratings) {
if (ratings == null || ratings.length < 0)
return -1;
int[] candys = new int[ratings.length];
@ninjachen
ninjachen / HeaderUntouchableListView.java
Created August 4, 2016 07:12
HeaderUntouchableListView
/**
* listView with header untouchable
* Created by ninja on 8/3/16.
*/
public class HeaderUntouchableListView extends ListView {
private View mHeaderView;
private boolean isDownEventConsumed;
public HeaderUntouchableListView(Context context, AttributeSet attrs) {
super(context, attrs);

Keybase proof

I hereby claim:

  • I am ninjachen on github.
  • I am ninjachen (https://keybase.io/ninjachen) on keybase.
  • I have a public key ASCnbH5syCey_8XwaqirnZ0Zs7tjgM6UBOJ58zYlVJ2pLAo

To claim this, I am signing this object:

import io.reactivex.Observable;
import io.reactivex.subjects.PublishSubject;
import io.reactivex.subjects.Subject;
/**
* Build followed with http://blog.kaush.co/2014/12/24/implementing-an-event-bus-with-rxjava-rxbus/
* Created by ninja on 6/21/17.
*/
public class RxBus {
private static RxBus instance = new RxBus();
@ninjachen
ninjachen / layout_boarder_top_bottom.xml
Created July 27, 2017 10:15
android layout with top and bottom boarder
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item>
<shape android:shape="rectangle" >
<!--border color-->
<solid android:color="@color/d8grey"/>
</shape>
</item>
<item android:bottom="1dp" android:top="1dp">
<shape android:shape="rectangle" >
@ninjachen
ninjachen / user-rule.txt
Created October 10, 2017 02:44
Ninja's user rule for PAC
! Put user rules line by line in this file.
! See https://adblockplus.org/en/filter-cheatsheet
||ip138.com^
||*.firebaseapp.com^
||*.notabug.org^
||*.docker.com^
||*.ocallahan.org^
@@||192.168.*
||*.fabric.io^
||fabric.io^

unicorn config file

Edit file /home/gitlab/gitlab/config/unicorn.rb

Find line listen "#{app_dir}/tmp/sockets/gitlab.socket" and comment it. Uncomment line listen "127.0.0.1:8080"

required modules for apache

  • sudo a2enmod proxy
  • sudo a2enmod proxy_http