Skip to content

Instantly share code, notes, and snippets.

Avatar
🥝
Food makes me happy

Ninja Chen ninjachen

🥝
Food makes me happy
  • Shanghai, China
View GitHub Profile
View how-to-set-up-stress-free-ssl-on-os-x.md

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

View gist:d7cabce1acfe10e00c7d
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;
View gist:850a6248f3d6a1bc09fd
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];
View HeaderUntouchableListView.java
/**
* 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);
View keybase.md

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:

View gist:34236178ddd5d0d1154a21b38c909429
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 Jul 27, 2017
android layout with top and bottom boarder
View layout_boarder_top_bottom.xml
<?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 Oct 10, 2017
Ninja's user rule for PAC
View user-rule.txt
! 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^
View README.md

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