Skip to content

Instantly share code, notes, and snippets.

@syxc
syxc / ProxySettings.java
Created May 14, 2012 08:45 — forked from madeye/ProxySettings.java
Set proxy for Android Webview
package me.madeye;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import org.apache.http.HttpHost;
import android.content.Context;
@syxc
syxc / fragment.java
Created May 23, 2012 09:25
动态加载fragment时需要注意!
// ...
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
Log.i(TAG, "-- onCreateView(...) --");
mRootView = (View) inflater.inflate(R.layout.fragment_login, container, false);
return mRootView;
}
// 当FragmentActivity动态切换Fragment的时候,上面代码片段中的container设置为null或者其后的参数设置为false,
// 否则会报出异常:
@syxc
syxc / 修复系统权限错误.txt
Created May 29, 2012 06:23
sudo chmod 777 / 惨剧修复简单步骤
sudo chmod 777 /
sudo chmod 777 -R /
Linux下以上命令的危害性,试过的人都会觉得可怕,有些人遇到这种情况,第一反应是没救了,其实,你要愿意花功夫去折腾,还是有办法滴!
下面理了下怎么折腾:
道具:
A、B两台电脑,假设都装着Ubuntu 12.04版本的系统,都能ssh、root(平时装Linux的时候这两个最好都弄好了,以备不时之需)。
情景:
现假设「A」是那台悲剧的执行过「sudo chmod 777 /」的电脑,什么效果,就不说了,反正不是什么好事,如果好奇,一试便知!
@syxc
syxc / SyncService.java
Created August 30, 2012 11:02
IntentService/ResultReceiver
/*
* Copyright 2011 Google Inc.
*
* 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
*
* Unless required by applicable law or agreed to in writing, software
@syxc
syxc / DownLoadFile.cs
Created November 13, 2012 05:22
C# Http文件下载公共类(支持断点续传)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Net;
namespace XcDownLoadFile
{
public class DownLoadFile
@syxc
syxc / windows.h__.js
Created November 19, 2012 01:54
windows.h.js INFINITY
var ffi = require('ffi'),
ref = require('ref'),
Struct = require('ref-struct'),
Library = require('./Library'),
Type = ref.Type,
NULL = ref.NULL,
isNull = ref.isNull;
var groups = ['libs', 'types', 'structs', 'callbacks', 'enums'];
@syxc
syxc / app.js
Created December 13, 2012 15:23 — forked from pixelhandler/app.js
var application_root = __dirname,
express = require("express"),
path = require("path"),
mongoose = require('mongoose');
var app = express.createServer();
// database
mongoose.connect('mongodb://localhost/ecomm_database');
- (void) viewDidLoad {
//...
comments.text = @"Comments";
comments.textColor = [UIColor lightGrayColor];
isEmpty = YES;
//...
}
- (BOOL)textViewShouldBeginEditing:(UITextView*)textView {
if (isEmpty) {
/*global $*/
(function () {
'use strict';
var $html = $('#html'),
$convert = $('#convert'),
$jade = $('#jade');
function normalizeLineBreaks(str) {
return str.replace(/(\r\n|\n|\r)/gm, '\n');
#import <UIKit/UIKit.h>
@interface UITextField (HideKeyBoard)
-(void)hideKeyBoard:(UIView *)view;
@end