Skip to content

Instantly share code, notes, and snippets.

View smartweb's full-sized avatar

Sam Chueng smartweb

  • Shenzhen Guangdong China
View GitHub Profile
@smartweb
smartweb / eventbrite-multi-discount.rb
Created September 27, 2011 06:45 — forked from ryanj/eventbrite-multi-discount.rb
a script to help automate adding or updating discount codes for multiple events
#!/usr/bin/ruby
#
# This work is licensed under a Creative Commons Attribution 3.0 Unported License.
# http://creativecommons.org/licenses/by/3.0/
#
# With some slight modifications, this script should create
# a new discount code for each of the 'live' events which are
# owned by the user (who is identified by the user_key value).
#
# See the above license info and Eventbrite API terms for usage limitations.
@smartweb
smartweb / gist:1252349
Created September 30, 2011 00:39
More Icon, Not Image
http://somerandomdude.com/articles/design-technology/font-embedding-icons/
The basic idea is to generate a font containing your icons (much like wingding font sets), embedding that font using the @font-face CSS rule and taking advantage of the :before selector and content rule to inject a character bound to a specific icon.
@smartweb
smartweb / object-c-debug-tips
Created February 7, 2012 00:26
object-C开发调试技巧:跟踪输出来源
调试技术,跟踪输出来源,DLog和ALog
#ifdef DEBUG
#define DLog(fmt, ...)
NSLog((@"%s [Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__);
#else
#define DLog(...)
#endif
// ALog always displays output regardless of the DEBUG setting
#define ALog(fmt,...) NSLog((@"%s [Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__,##__VA_ARGS__);
@smartweb
smartweb / object-gloabl-variable
Created February 7, 2012 00:31
iPhone 开发,全局变量的使用
先在App的入口文件[YourPrefix]AppDelegate定义
#define AppDelegate (XYAppDelegate *)[[UIApplication sharedApplication] delegate]
全局变量定义为AppDelegate的属性
然后在项目的其他文件中引入 AppDelegate.h
使用[AppDelegate 全局变量]就可以访问全局变量,比如baseURL
@smartweb
smartweb / iPhone-send-sms
Created February 7, 2012 00:33
iPhone开发,发送短信
[[UIApplication sharedApplication] openURL: @"sms:12345678"];
MFMessageComposeViewController *controller = [[[MFMessageComposeViewControlleralloc] init] autorelease];
if([MFMessageComposeViewControllercanSendText])
{
controller.body= @"SMS content";
# 接收短信人的号码
controller.recipients = [NSArrayarrayWithObjects:@"12345678", @"87654321", nil];
controller.messageComposeDelegate =self;
@smartweb
smartweb / iPhone-keyboard-hide
Created February 7, 2012 00:43
iPhone开发,中文输入时弹出键盘会遮住输入框,解决方法
实现以下三个方法,如果弹出的键盘会遮住输入框 ,整体的界面会向上移动,这样就不会遮住输入框了。自己增加UITextFieldDelegate委托。
只适合iPhone,如果想要支持iPad,只要把216改成iPad上面键盘的高度即可。
- (void)keyboardWillShow:(NSNotification *)noti
{
//键盘输入的界面调整
//键盘的高度
float height = 216.0;
CGRect frame = self.view.frame;
frame.size = CGSizeMake(frame.size.width, frame.size.height - height);
@smartweb
smartweb / motion_local_notification.rb
Last active August 29, 2015 13:57
添加本地通知
def add_local_notification
local_noti = UILocalNotification.alloc.init
return if local_noti.nil?
NSLog("添加本地消息通知")
now = NSDate.now
# 触发通知的时间
local_noti.fireDate = now.dateByAddingTimeInterval(10)
# 循环次数,kCFCalendarUnitWeekday一周一次
local_noti.repeatInterval =0
@smartweb
smartweb / motion_shoot.rb
Last active August 29, 2015 13:57
点击拍照或从相册获取照片
# 需要加入BubbleWrap和Sugarcube 的Gem
def shoot
UIActionSheet.alert('', buttons: [nil, nil, '马上拍一张', '从手机相册选择', '返回']) do |pressed|
case pressed
when '马上拍一张'
BW::Device.camera.rear.picture(media_types: [:movie, :image]) do |result|
set_photo(result[:original_image])
end
when '从手机相册选择'
BW::Device.camera.any.picture(media_types: [:movie, :image]) do |result|
@smartweb
smartweb / gist:7fbec0208cd1c18cb367
Created November 25, 2015 03:18
友盟ShareSDK第三方登录
UMSocialSnsPlatform *snsPlatform = [UMSocialSnsPlatformManager getSocialPlatformWithName:platformName];
snsPlatform.loginClickHandler(self,
[UMSocialControllerService defaultControllerService],
YES,
^(UMSocialResponseEntity *response){
//code
});