Skip to content

Instantly share code, notes, and snippets.

@slashthinking
slashthinking / firebase_first_item.js
Created June 20, 2015 09:36
获得列表中的第一个
function makeList(ref) {
var fruits = ["banana", "apple", "grape", "orange"];
for (var i = 0; i < fruits.length; i++) {
ref.push(fruits[i]);
}
}
function getFirstFromList(ref, cb) {
ref.startAt().limit(1).once("child_added", function(snapshot) {
cb(snapshot.val());
@slashthinking
slashthinking / data-structure.js
Created June 20, 2015 09:35
用户分组权限
/*
This example shows how you can use your data structure as a basis for
your Firebase security rules to implement role-based security. We store
each user by their Twitter uid, and use the following simplistic approach
for user roles:
0 - GUEST
10 - USER
20 - MODERATOR
@slashthinking
slashthinking / using_an_index.js
Created June 20, 2015 09:32
通过邮箱名搜索用户
/***************************************************
* Assuming you can't use priorities (e.g. they are already being used for something else)
* You can store the email addresses in an index and use that to match them to user ids
***************************************************/
var fb = new Firebase(URL);
/**
* Looks up a user id by email address and invokes callback with the id or null if not found
* @return {Object|null} the object contains the key/value hash for one user
@slashthinking
slashthinking / check_user_exist.js
Created June 20, 2015 09:24
检查用户是否存在
function go() {
var userId = prompt('Username?', 'Guest');
checkIfUserExists(userId);
}
var USERS_LOCATION = 'https://SampleChat.wilddogio.com/users';
function userExistsCallback(userId, exists) {
if (exists) {
alert('user ' + userId + ' exists!');
<?xml version="1.0" encoding="utf-8"?>
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
android:versionCode="49466"
android:versionName="2.0.3-release"
android:installLocation="0"
package="com.facebook.orca"
>
<uses-sdk
android:minSdkVersion="8"
package com.facebook.analytics;
import android.app.ActivityManager;
import android.app.ActivityManager.MemoryInfo;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.content.res.Configuration;
@slashthinking
slashthinking / line.java
Last active November 24, 2016 06:52
LINE研究
package jp.naver.android.npush.register;
import android.app.AlarmManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import jp.naver.android.npush.common.Logger;
import jp.naver.android.npush.common.NPushIntent;
public class NPushMessaging
@slashthinking
slashthinking / WatchDogPushReceiver.java
Last active August 31, 2024 06:20
微信代码研究
package com.tencent.mm.modelstat;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import com.tencent.mm.sdk.platformtools.l;
import com.tencent.mm.sdk.platformtools.q;
import com.tencent.mm.t.a.i;
import com.tencent.mm.t.au;
@slashthinking
slashthinking / gist:4701959
Created February 3, 2013 14:14
qq源码中的获取屏幕截屏的代码,很有意思。
public static Bitmap screenshot(Context paramContext)
{
boolean bool = sLoadSO;
Bitmap localBitmap = null;
if (bool);
try
{
byte[] arrayOfByte = getFrameBuffer();
localBitmap = null;
if (arrayOfByte == null)
ConnectivityManager connectivity = (ConnectivityManager)context.getSystemService(Context.CONNECTIVITY_SERVICE);
if (connectivity != null) {
// 获取网络连接管理的对象
NetworkInfo info = connectivity.getActiveNetworkInfo();
if (info != null && info.isConnected()) {
// 判断当前网络是否已经连接
if (info.getState() == NetworkInfo.State.CONNECTED) {
if(info.getTypeName().equals("WIFI")){