Skip to content

Instantly share code, notes, and snippets.

@waveacme
waveacme / LocalBroadcastExampleActivity.java
Last active January 15, 2016 02:18 — forked from Antarix/LocalBroadcastExampleActivity.java
Simple Example of using LocalBroadcastManager in Android
import android.app.Activity;
import android.app.Service;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
import android.os.IBinder;
import android.support.v4.content.LocalBroadcastManager;
@waveacme
waveacme / MainActivity.java
Created January 15, 2016 02:49
how to check service running stat in android
public class MainActivity extends Activity {
//...
public void CheckService(View v) {
boolean isRunning = isMyServiceRunning(myService.class);
Log.d(TAG, "my service running status: " + isRunning);
}
private boolean isMyServiceRunning(Class<?> serviceClass) {
ActivityManager manager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
@waveacme
waveacme / MyHandlerThread.java
Created January 15, 2016 03:04
fix Cannot resolve sambol 'THREAD_PRIORITY_BACKGROUND' in HandlerThread
//fix
import android.os.Process;
HandlerThread thread = new HandlerThread("work thread", Process.THREAD_PRIORITY_BACKGROUND);
@waveacme
waveacme / DecodeActivity.java
Created January 15, 2016 08:30
MediaCodec decode h264 example
//from https://github.com/vecio/MediaCodecDemo
package io.vec.demo.mediacodec;
import java.nio.ByteBuffer;
import android.app.Activity;
import android.media.MediaCodec;
import android.media.MediaCodec.BufferInfo;
@waveacme
waveacme / json_post_example.c
Last active March 11, 2016 03:53
use libcurl and json-c to build and send http post package in c
#include <stdio.h>
#include <string.h>
#include <json/json.h>
#include <curl/curl.h>
/*
* to install lib:
* apt-cache search ^libcurl
* apt-get install <whatever_apt-cache_listed>
@waveacme
waveacme / Makefile
Created March 17, 2016 08:14
general Makefile
CC=gcc
CFLAGS=-Wall -IDIR
LDFLAGS=-LDIR -lfoo
TARGET= a.out
#SOURCES=bar.c
SOURCES=$(wildcard *.c)
OBJECTS=$(SOURCES:.c=.o)
@waveacme
waveacme / ViewController.swift
Created March 18, 2016 09:19
text filed delegate sample
//
// ViewController.swift
// FoodTracker
//
// Created by Jane Appleseed on 5/23/15.
// Copyright ? 2015 Apple Inc. All rights reserved.
// See LICENSE.txt for this sample’s licensing information.
//
import UIKit
@waveacme
waveacme / logger.c
Created March 25, 2016 02:45
a macro logger for c
#include "logger.h"
int DebugLevel = DEBUG_WARN;
int main(void)
{
DBGPRINT(DEBUG_WARN, ("hello,debug=%s\n", "aaa"));
return 0;
}
@waveacme
waveacme / example.c
Last active April 12, 2023 12:07
linux list.h for userspace
#include <stdlib.h>
#include <stdio.h>
#include "list.h"
typedef struct episode {
int epid;
struct list_head list;
} episode_t;
@waveacme
waveacme / UITableView+reloadDataAnimated.m
Created April 6, 2016 08:24 — forked from tony0x59/UITableView+reloadDataAnimated.m
tableview重载数据时的淡入淡出动画过渡效果
#import "UITableView+reloadDataAnimated.h"
@implementation UITableView (reloadDataAnimated)
- (void)reloadDataWithAnimated:(BOOL)animated
{
[self reloadData];
if (animated) {
CATransition *animation = [CATransition animation];