Skip to content

Instantly share code, notes, and snippets.

View juwencheng's full-sized avatar
🏠
Working from home

Juwencheng juwencheng

🏠
Working from home
View GitHub Profile
@juwencheng
juwencheng / curl_get.php
Last active April 9, 2019 23:57
PHP 使用 curl 发送 post 请求,可以自定义header和传递参数
/**
* Send a GET requst using cURL
* @param string $url to request
* @param array $get values to send
* @param array $options for cURL
* @return string
*/
function curl_get($url, array $get = NULL, array $options = array())
{
$defaults = array(
@juwencheng
juwencheng / bottom_navigation_bar
Created March 7, 2019 12:35
底部导航栏,可以自定义选中字体的,from flutter/packages/flutter/lib/src/material/bottom_navigation_bar.dart
// Copyright 2016 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.
import 'dart:collection' show Queue;
import 'dart:math' as math;
import 'package:flutter/widgets.dart';
import 'package:vector_math/vector_math_64.dart' show Vector3;
@juwencheng
juwencheng / MultiThreadObject.m
Created October 5, 2018 00:56
iOS多线程问题演示
@interface MultiThreadObject: NSObject
@property (nonatomic, strong) NSArray *data;
@end
@implementation MultiThreadObject
@end
@juwencheng
juwencheng / image_and_text_in_stack.dart
Created August 22, 2018 08:57
使用Stack布局创建图文重叠的效果
new Stack(
children: <Widget>[
new Positioned.fill(
child: new FadeInImage(
placeholder: new AssetImage('placeholder.png'),
image: new CachedNetworkImageProvider(photos[int].url),
fit: BoxFit.contain,
alignment: Alignment.center,
fadeInDuration: new Duration(milliseconds: 200),
fadeInCurve: Curves.linear,
@juwencheng
juwencheng / image_and_text_in_stack.dart
Created August 22, 2018 08:57
使用Stack布局创建图文重叠的效果
new Stack(
children: <Widget>[
new Positioned.fill(
child: new FadeInImage(
placeholder: new AssetImage('placeholder.png'),
image: new CachedNetworkImageProvider(photos[int].url),
fit: BoxFit.contain,
alignment: Alignment.center,
fadeInDuration: new Duration(milliseconds: 200),
fadeInCurve: Curves.linear,
@juwencheng
juwencheng / image_and_text_in_stack.dart
Created August 22, 2018 08:56
使用Stack布局创建图文重叠的效果
new Stack(
children: <Widget>[
new Positioned.fill(
child: new FadeInImage(
placeholder: new AssetImage('placeholder.png'),
image: new CachedNetworkImageProvider(photos[int].url),
fit: BoxFit.contain,
alignment: Alignment.center,
fadeInDuration: new Duration(milliseconds: 200),
fadeInCurve: Curves.linear,
@juwencheng
juwencheng / streambuilder_widget_test.dart
Created August 19, 2018 13:06
This is a simple example to test a StreamBuilder widget, which data are from http request.
// This is a basic Flutter widget test.
// To perform an interaction with a widget in your test, use the WidgetTester utility that Flutter
// provides. For example, you can send tap and scroll gestures. You can also use WidgetTester to
// find child widgets in the widget tree, read text, and verify that the values of widget properties
// are correct.
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:rxdart/rxdart.dart';
@juwencheng
juwencheng / web-servers.md
Created July 8, 2018 01:34 — forked from willurd/web-servers.md
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
@juwencheng
juwencheng / post_form_data.m
Created April 13, 2018 02:46
POST multipart/form-data with Objective-C| 同时上传多张图片和参数的方式 Objective-C/Swift
- (NSData *)createBodyWithBoundary:(NSString *)boundary
parameters:(NSDictionary *)parameters
paths:(NSArray *)paths
fieldName:(NSString *)fieldName {
NSMutableData *httpBody = [NSMutableData data];
// add params (all params are strings)
[parameters enumerateKeysAndObjectsUsingBlock:^(NSString *parameterKey, NSString *parameterValue, BOOL *stop) {
[httpBody appendData:[[NSString stringWithFormat:@"--%@\r\n", boundary] dataUsingEncoding:NSUTF8StringEncoding]];
@juwencheng
juwencheng / resolveInstanceMethod.m
Created March 7, 2018 07:09
通过 resolveInstanceMethod: 解决无法找到selector导致的奔溃。
#import <Foundation/Foundation.h>
@interface MisImp : NSObject
- (void)foo;
+ (void)fooMethod;
@end
#import "MisImp.h"