Skip to content

Instantly share code, notes, and snippets.

@wjx
wjx / record_stream.c
Created May 6, 2015 09:00
Android record_stream: A simple utility for reading fixed records out of a stream fd, usage:hardware/ril/libril/ril.cpp
/* libs/cutils/record_stream.c
**
** Copyright 2006, The Android Open Source Project
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
** http://www.apache.org/licenses/LICENSE-2.0
**
/* $OpenBSD: strtol.c,v 1.10 2014/09/13 20:10:12 schwarze Exp $ */
/*
* Copyright (c) 1990 The Regents of the University of California.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the f
@wjx
wjx / archive.py
Created April 30, 2015 11:16
Archive hi.baidu.com articles.
#!/usr/bin/env python
import os
import sys
import io
import re
import requests
from bs4 import BeautifulSoup
from time import sleep
import random
@wjx
wjx / pickle.cc
Last active August 29, 2015 14:20
Chromium pickle
//https://code.google.com/p/chromium/codesearch#chromium/src/base/pickle.cc
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "base/pickle.h"
#include <stdlib.h>
#include <algorithm> // for max()
@wjx
wjx / GsmAlphabet.java
Last active August 29, 2015 14:19
Android sms parse
frameworks/base/telephony/java/com/android/internal/telephony/GsmAlphabet.java
static {
int numTables = sLanguageTables.length;
sCharsToGsmTables = new SparseIntArray[numTables];
for (int i = 0; i < numTables; i++) {
String table = sLanguageTables[i];
int tableLen = table.length();
@wjx
wjx / IccUtils.java
Last active August 29, 2015 14:19
hexStringToBytes/bytesToHexString
android/frameworks/opt/telephony/src/java/com/android/internal/telephony/uicc/IccUtils.java
static int
hexCharToInt(char c) {
if (c >= '0' && c <= '9') return (c - '0');
if (c >= 'A' && c <= 'F') return (c - 'A' + 10);
if (c >= 'a' && c <= 'f') return (c - 'a' + 10);
throw new RuntimeException ("invalid hex char '" + c + "'");
}
@wjx
wjx / ply-key-file.c
Created April 24, 2015 06:21
Plymouth parse config file like /lib/plymouth/themes/ubuntu-logo/ubuntu-logo.plymouth
plymouth/src/libply/ply-key-file.c
static bool
ply_key_file_load_groups (ply_key_file_t *key_file)
{
int items_matched;
bool added_group = false;
bool has_comments = false;
do {