Skip to content

Instantly share code, notes, and snippets.

@bloatfan
bloatfan / utf8.php
Created May 9, 2017 13:57
gbk utf8 check
<?php
// refer: http://hustnaive.github.io/php/2015/08/21/php-detect-encoding.html
/**
* 检测字符串编码(注意:存在误判的可能性,降低误判的几率的唯一方式是给出尽可能多的样本$line)
* 检测原理:对给定的字符串的每一个字节进行判断,如果误差与gb18030在指定误差内,则判定为gb18030;与utf-8在指定误差范围内,则判定为utf-8;否则判定为utf-16
* @param string $line
* @return string 中文字符集,返回gb18030(兼容gbk,gb2312,ascii);西文字符集,返回utf-8(兼容ascii);其他,返回utf-16(双字节unicode)
* @author fangl
yum install -y libpng
yum install -y libjpeg
yum install -y openssl
yum install -y icu
yum install -y libX11
yum install -y libXext
yum install -y libXrender
yum install -y xorg-x11-fonts-Type1
yum install -y xorg-x11-fonts-75dpi
@JonCole
JonCole / Redis-DebuggingKeyspaceMisses.md
Last active March 6, 2025 07:20
Redis Debugging Tips

Debugging Redis Keyspace Misses

Simply put, a keyspace "MISS" means some piece of data you tried to retrieve from Redis was not there. This usually means that one of the following things happened:

  1. The key expired
  2. They key was renamed
  3. The key was deleted
  4. The key was evicted due to memory pressure
  5. The entire database was flushed
  6. The key was never actually inserted
@brianspiering
brianspiering / .bash_profile
Last active June 16, 2023 18:08
This file holds all my BASH configurations and aliases
# ---------------------------------------------------------------------------
#
# Description: This file holds all my BASH configurations and aliases
#
# Sections:
# 1. Environment Configuration
# 2. Make Terminal Better (remapping defaults and adding functionality)
# 3. File and Folder Management
# 4. Searching
# 5. Process Management
@evantoli
evantoli / GitConfigHttpProxy.md
Last active May 6, 2025 06:33
Configure Git to use a proxy

Configure Git to use a proxy

In Brief

You may need to configure a proxy server if you're having trouble cloning or fetching from a remote repository or getting an error like unable to access '...' Couldn't resolve host '...'.

Consider something like:

@drmalex07
drmalex07 / README-setup-tunnel-as-systemd-service.md
Last active April 7, 2025 13:24
Setup a secure (SSH) tunnel as a systemd service. #systemd #ssh #ssh-tunnel #ssh-forward

README

Create a template service file at /etc/systemd/system/[email protected]. The template parameter will correspond to the name of target host:

[Unit]
Description=Setup a secure tunnel to %I
After=network.target
@Ulu2005
Ulu2005 / cmu_course.md
Created July 13, 2015 21:45
CMU CS Course Info

#CMU Course Info 整理自一亩三分地

##08722 – Data Structurefor application programmers 这门课主要是开给EBIZ和MISM的,在MISM那边的课号是95772. 但是很多ECE, INI的同学,以及咱ME转CS帮都在上这门课。这门课只有半学期,一共6个credits,相当于1.5学分。内容非常基础,但是我觉得帮助挺大的,对于非CS科班出身想转CS的同学非常建议上一下, 基础越弱收获越大,要是基础比较硬的话就不用上了。LZ上的其它CS的课几乎都是各种牛校的PHD出身,这门课的老师好像都没有PHD学位,肯定没法去上15的课,但是讲课挺用心,讲的也很清楚。讲课这东西真的不是老师自己越牛就讲的越好。尤其数据结构这种比较基础的内容。这门课从最简单的内容讲起,包括array, arraylist, linked list, stack, queue,sorting(bubble, selection, insertion, merge, quick, heap), hashTable, hashMap,hashSet, BST, TreeMap, TreeSet, Huffman coding, Heap. 每周一次quiz, lab, homework。讲的时候内容都围绕Java Collection 来讲,还涉及与collection有关的comparator, iterator 等内容。这门课完全就是针对面试的,作业要求先手写代码(虽然大部分时候都是先ECLIPSE敲好再抄到纸上的)。

6次homework,前面的非常简单,后面稍微麻烦一点,难度都不大,就是让你去熟悉这些数据结构能自己implement,也能用JAVA COLLECTION。

  1. 自己implement 一个 arraylist 实现各种要求
  2. Queue, stack 的implement和应用
@josephg
josephg / 0dedict.py
Last active April 20, 2025 10:59
Apple dictionaries
# Thanks to commenters for providing the base of this much nicer implementation!
# Save and run with $ python 0dedict.py
# You may need to hunt down the dictionary files yourself and change the awful path string below.
# This works for me on MacOS 10.14 Mohave
from struct import unpack
from zlib import decompress
import re
filename = '/System/Library/Assets/com_apple_MobileAsset_DictionaryServices_dictionaryOSX/9f5862030e8f00af171924ebbc23ebfd6e91af78.asset/AssetData/Oxford Dictionary of English.dictionary/Contents/Resources/Body.data'
f = open(filename, 'rb')
// by Erik Wrenholt
import java.util.*;
class Mandelbrot
{
static int BAILOUT = 16;
static int MAX_ITERATIONS = 1000;
private static int iterate(float x, float y)
{
@mingfang
mingfang / convert id_rsa to pem
Last active December 12, 2024 12:13
Convert id_rsa to pem file
openssl rsa -in ~/.ssh/id_rsa -outform pem > id_rsa.pem
chmod 600 id_rsa.pem