Skip to content

Instantly share code, notes, and snippets.

View c9n's full-sized avatar
🎯
Focusing

Lynn c9n

🎯
Focusing
View GitHub Profile
@c9n
c9n / cities.lua
Last active May 18, 2021 09:59
市级城市区划码
cities = {
[1100] = "北京市",
[1101] = "北京市",
[1102] = "北京市",
[1200] = "天津市",
[1201] = "天津市",
[1202] = "天津市",
[1300] = "河北省",
[1301] = "石家庄市",
[1302] = "唐山市",
@c9n
c9n / isset_and_is_null.php
Created January 6, 2016 02:57
Test isset & is_null
<?php
$a = 'c9n';
/* ----- isset ----- */
$start = microtime(true);
for ($i = 0; $i < 1000 * 1000; $i++) {
@c9n
c9n / html_entity.php
Created January 5, 2016 08:16
HTML entities
<?php
$test = mb_convert_encoding('徐若瑄', 'HTML-ENTITIES', 'UTF-8');
echo $test . "\n";
echo html_entity_decode($test);
@c9n
c9n / installation.sh
Created January 4, 2016 05:25
在 Mac 下编译安装 OpenResty
#!/usr/bin/env sh
pwd # /Users/Lynn/Desktop
brew install pcre
wget https://www.openssl.org/source/openssl-1.0.2e.tar.gz
tar xvf openssl-1.0.2e.tar.gz
@c9n
c9n / rpm-from-source.sh
Last active December 14, 2015 09:20 — forked from fernandoaleman/rpm-from-source.sh
How to create an RPM from source with spec file
# How to create an RPM from source with spec file
# This is for Redhat versions of linux. Sometimes when you search for an rpm package,
# it is either outdated or not available. The only thing available is the source code.
# You can create a custom RPM package from source.
#
# For this example, I'll be using the latest version of Git, currently v.1.7.7.3
# Step: 1
# Install rpmbuild
@c9n
c9n / Test.java
Created December 8, 2015 09:40
Java - Get max heap size
// javac Test.java
// java -Xmx512m Test
public class Test {
public static void main(String[] args) {
System.out.println("----------");
long max = Runtime.getRuntime().maxMemory();
System.out.println(max/1024/1024 + "M");
}
}
@c9n
c9n / rsa_demo.c
Created November 17, 2015 13:04
openssl RSA demo
#include <openssl/rsa.h>
#include <openssl/pem.h>
#include <openssl/err.h>
#include <stdio.h>
#include <string.h>
#define KEY_LENGTH 2048
#define PUB_EXP 3
#define PRINT_KEYS
#define WRITE_TO_FILE
@c9n
c9n / kafka_consumer.cpp
Created September 23, 2015 08:21
librdkafka consumer
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <csignal>
#include <cstring>
#include <getopt.h>
#include "rdkafkacpp.h"
/* for loop */
@c9n
c9n / pom.xml
Created January 26, 2015 08:13
Sample
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>com.redwoods.app</groupId>
<artifactId>demo</artifactId>
<version>0.0.1</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
@c9n
c9n / WeixinApi.php
Created January 14, 2015 07:17
获取微信 jsapi_ticket
<?php
Class WeixinApi {
private $appid;
private $secret;
function __construct ($appid, $secret) {
$this->appid = $appid;
$this->secret = $secret;