Skip to content

Instantly share code, notes, and snippets.

View browny's full-sized avatar
👨‍💻

Browny Lin browny

👨‍💻
View GitHub Profile
@browny
browny / gist:1113176
Created July 29, 2011 05:16
[Java] Access modifier of an overriding method
class Base {
private int privMethod() { return 1; }
int packMethod() { return 1; }
protected int protMethod() { return 1; }
public int pubMethod() { return 1; }
}
class Derived extends Base {
@browny
browny / gist:1113253
Created July 29, 2011 06:09
[C++] Make protected/private inherited members public
#include <iostream>
using namespace std;
class Base {
private:
int a;
int privMethod() { return a; }
Chap5. BufferQueue 和 Comsumer 的關係
void Layer::onFirstRef()
{
struct FrameQueuedListener : public SurfaceTexture::FrameAvailableListener {
FrameQueuedListener(Layer* layer) : mLayer(layer) { }
private:
wp<Layer> mLayer;
virtual void onFrameAvailable() {
@browny
browny / simple_socket_example.c
Last active June 2, 2024 19:25
simple socket example in C
/* --- Usage --- */
g++ server.c -o server
g++ client.c -o client
./server
./client 127.0.0.1
/* --- server.c --- */
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
@browny
browny / min_coins.cpp
Created March 31, 2013 08:32
Given a list of N coins, their values being in an array A[], return the minimum number of coins required to sum to S (you can use as many coins you want). If it's not possible to sum to S, return -1
#include <cmath>
#include <vector>
#include <iostream>
using namespace std;
// greedy
int minCoins_greedy(vector<int> a, int sum) {
sort(a.begin(), a.end(), greater<int>()); // sorted in descending order
a.erase(unique(a.begin(), a.end()), a.end()); // remove duplicates

###Workaround for welcome latter

  1. Subscribe the user to List

     ListSubscribeMethod req1 = new ListSubscribeMethod();
     req1.apikey = API_KEY;
     req1.id = LIST_ID;
     req1.email_address = "xxxx@gmail.com";
     // There is no need to send confirm letter
    

req1.double_optin = false;

[user]
name = <Your Name>
email = <Your Emain>
[core]
excludesfile = ~/.gitignore
pager = less -FXrS -x4
filemode = false
whitespace = cr-at-eol
editor = vim

Git Diff

git diff                 // Look diff from previous commited version

git diff > temp.patch    // Output diff to patch file
git apply temp.patch     // Apply patch 'pk_xxx'

git reset --hard 6a137   // Force reset to version '6a137' will lost new commit

git format-patch HEAD^^^ // Patch to nth(^) previos version from HEAD, output multiple files

@browny
browny / colorful_tail.sh
Created November 15, 2013 03:15
The bash script make the log colorful with specified tag
#!/bin/bash
TAIL=`which tail`
AWK=`which awk`
if [[ -z $TAIL ]]; then
echo -e "Cannot find tail executable.\n"
exit 1
fi
if [[ -z $AWK ]]; then
echo -e "Cannot find awk executable.\n"
exit 1
@browny
browny / twstock_name.py
Created September 15, 2014 23:37
Get TW stock name by its number
# requirements:
# beautifulsoup4==4.3.2
# uniout==0.3.7
import sys
import urllib2
import re
import uniout
from bs4 import BeautifulSoup
from pprint import pprint