Skip to content

Ider

沉淀我所学习,累积我所见闻,分享我所体验

Primary Navigation Menu
Menu
  • Home
  • About Ider
    • Who Ider?
    • Why Ider?
    • How Ider?
    • Where Ider?
    • What Ider?
2014-03-31
31 March
On March 31, 2014
In Data Structures(数据结构), English Posts(英文写作), Language Tips(语言初试), Mobile Development(移动开发)

Introduction to Loc (Lua Objective-C)

Recently we were starting to use Lua in our game. Lua is a very popular scripting language in the game industry. It’s written in pure C and is very lightweight. We can simply add Lua source code to our project, and it is very easy to compile and run.

However, in practice we encountered issues with type conversion between Lua and Objective-C. In the beginning, we followed instructions to create C functions, and inside the functions we called Objective-C methods, then registered those functions into Lua State as library. When requirements went more complicated, we have to create a bunch of C functions, which are redundancy in a lot of places. This is really not an ideal to bridge between Lua and Objective-C.

After reading the Lua instructions for two days, and with knowledge about iOS7 JavaScript Framework, I decided to create a similar framework to handle type conversion between these two languages. The good thing is Objective-C is a superclass of C, and Lua is naturally compiled from C, this makes it very easy to construct a bridge and make them communicating with each other. With reflection from Objective-C, it’s also very convenient to call Objective-C methods from Lua.

Loc (Lua Objective-C) is the framework I created to convert type between Lua and Objective-C for our project. It’s as simple as Lua, with only 6 packages. It reduces a lot of time to create functions mapping Lua call, and it works pretty well so far.

With the permission from my company, I shared the slides that I presented to my colleagues about the design and syntax about Loc. I am trying to persuade my managers to make it open source, so more developers could use it to prove the usability and make the framework more mature.

2014-02-28
28 February
On February 28, 2014
In Programming Life(程序人生)

他们的现在,可能是我的将来

四年前,我还是个刚刚参加实习没毕业的学生,跟着老板学到了好多东西。而现在我离开校园工作了差不多快两年。在工作中,除了不断自我学习,网上搜索答案,很多时候也得到前辈同事的指点和帮助。当他们开始写代码的时候,我可能还在上初中,他们的经验和经历可能各不相同,而我要走的路也不会跟他们完全一样。但是身在同一个行业里的同一种职业上,他们走过的路也多少让我了解,在哪条路我能奔跑起来,在哪条路上我会陷入泥潭。
Read More →

2014-01-17
17 January
On January 17, 2014
In Article Collection(聚宝收藏), English Posts(英文写作), Language Tips(语言初试)

Redis Command Reference

Redis is really awesome key-value storage. Not only because it is very fast on data get/set as all data are stored in memory, but also it is very simple to setup even from source code, it has multiple data structures that can be used in practice, and it is well documented, many useful resources can be found in Redis.io.

The most valuable thing of Redis should be the commands that communicate with Redis server to operate on data. On Redis.io, there is page fully explained the functionality of each commands, it also provides some interactive page to try each command and know them well.

Here I restyle the commands page, so that they could be print out in two papers, and also highlighted them with different color according to their type. You can download the PDF file here as well.

2014-01-02
02 January
On January 2, 2014
In IT Products(数码产品), Mobile Development(移动开发)

利用Android的Tethering变手机为Wifi基站分享数据流量

网络现在似乎越来越成了马斯洛人类需求五层次理论之外的第六大更基本的需求,每个人手上的手机的电话功能变得越来越弱,数据流量变成了更加基本配置需要。家家户户也是牵入Wifi比牵入电视信号更重要。

HierarchyOfNeeds

平板电脑也越来越流行,但是一般只能链接Wifi,出了门连不上什么3G、4G也变成了一块只能砸人的砖头。要是想给平板配备数据流量,不仅设备上要付出额外的费用,平时有Wifi不常需要用到数据流量又变得很浪费。

这里跟大家分享个Android的功能,它可以让Android手机变成Wifi基站,让其它设备可以连接到手机上,使用该手机的数据流量。这样只要一部手机有数据流量,就能让家里其它设备在连不上Wifi的时候也能上网了。
Read More →

2013-12-26
26 December
On December 26, 2013
In Algorithm Analysis(算法分析), Data Structures(数据结构), Knowledge Base(心得笔库), Language Tips(语言初试), Special Tricks(奇技妙招)

bash中使用printf实现进制转换

最近工作中常涉及到编码转换的问题,比如发送URL的时候需要进行urlencode,上传内容的时候要对MD5进行BASE64的转换。当debug的只能看到8或者16进制的编码而想不到实际的字符是什么,就让人非常烦躁,所以总想有个什么快速的方式能帮助自己进行编码转换 。

最快的方式,应该就像小时候被乘法口诀表一样把他们的对应关系一一记住,但是可能年龄大了记住了东西,外加现在越来越依赖技术带来的便利所以总是不能也不愿意记这些进制关系,一碰到这些问题就Google搜索一下。但这显然这是很 浪费时间的。

如果是用Linux或者Mac系统,用Terminal的话就能带来很多的帮助,比如man ascii就会显出中ASCII在8、10和16进制下所有编码值了。这样子看到一个8或16进制的数,也能很快的找到对应的字符是什么了。不过这还是不过快,毕竟人眼查这样一张有序的表并不会进行二分查找。而且我们希望是能够在O(1)时间复杂度就能得到结果方法。

本文就总结怎么用printf的格式化在Bash环境中实现进制的转换,如果有那个比较好用或常用的,就可以添加到profile中在启动时载入使用。
Read More →

2013-12-02
02 December
On December 2, 2013
In Article Collection(聚宝收藏), Front Interface(界面构想), Special Tricks(奇技妙招)

CSS3实现关闭按钮

作为一名程序员,可以说有着较强的逻辑思维来编写程序代码,但是在界面设计上却常常因欠缺艺术思维而缺乏美观。在于前段开发的时候往往会碰到这样的窘境:能够用JavaScript实现功能、用CSS做好布局,但是在配色方面却显得无从下手。想要做Photoshop做一些效果图,却又不熟悉软件的使用,网上寻找到素材不是不能完全满足要求,就是有版权需要付费。作为一个公司可以聘请专业的美工人员来帮助完成这些需求,但是作为个人就只能自己想办法了。

幸好随着HTML5和CSS3标准化的一步步推进,各个浏览器对这些标准更加全面的支持和实现,许多以前靠依靠图片才能实现的效果,现在都可以通过CSS3的属性来实现。比如:让按钮看起来有立体感的阴影效果和渐变效果,以前只能放置背景图来实现,现在则可以用box-shadow和gradient来设置;以前想设计圆角边框,也得使用图片做背景,现在用border-radius就搞定了还能四个角区别设置。

在本文中将分享用CSS3设计出来的样式来呈现出关闭按钮的样子,这样以后想设计简单的对话框,就不需要求美工来帮忙画按钮的图片了。先来看看样式:

[codesyntax lang=”css” lines=”normal”]

/* basic style */
.close {
    /* still bad on picking color */
    background: orange;
    color: red;
    /* make a round button */
    border-radius: 12px;
    /* center text */
    line-height: 20px;
    text-align: center;
    height: 20px;
    width: 20px;
    font-size: 18px;
    padding: 1px;
}
/* use cross as close button */
.close::before {
    content: "\2716";
}
/* place the button on top-right */
.close {
    top: -10px;
    right: -10px;
    position: absolute;
}

[/codesyntax]Read More →

2013-11-04
04 November
On November 4, 2013
In Data Structures(数据结构), Knowledge Base(心得笔库), Language Tips(语言初试), Mobile Development(移动开发)

JavaScriptCore框架在iOS7中的对象交互和管理

之前一篇的文章中已经简单入门了iOS7中新加的JavaScriptCore框架的基本用法,十分的简单方便而且高效,不过也仅限于数值型、布尔型、字符串、数组等这些基础类型。本文将扩展到更复杂的类型,介绍一下该强大的框架是如何让Objective-C对象和JavaScript对象进行直接互通的。

为了方便起见,以下所有代码中的JSContext对象都会添加如下的log方法和eventHandler:

[codesyntax lang=”objc” lines=”normal”]

JSContext *context = [[JSContext alloc] init];
context.exceptionHandler = ^(JSContext *con, JSValue *exception) {
    NSLog(@"%@", exception);
    con.exception = exception;
};

context[@"log"] = ^() {
    NSArray *args = [JSContext currentArguments];
    for (id obj in args) {
        NSLog(@"%@",obj);
    }
};

[/codesyntax]
Read More →

2013-10-05
05 October
On October 5, 2013
In Design Patterns(设计模式), Language Tips(语言初试), Mobile Development(移动开发)

iOS7新JavaScriptCore框架入门介绍

前阵子,Apple正式发布了新的iOS 7系统,最大最直观的改变在于界面变得小清新范了,我也提到《iOS,你真的越来越像Android了》。不过对于移动开发者来说,除了要适应Xcode 5,最应该关注的还是iOS 7在开发接口的上的变化。概览Apple提供的官方文档《What’s New in iOS》,最最让我欣喜的是iOS 7中加入了JavaScriptCore框架。该框架让Objective-C和JavaScript代码直接的交互变得更加的简单方便。

JavaScriptCore

这个框架其实只是基于webkit中以C/C++实现的JavaScriptCore的一个包装,在旧版本iOS开发中,很多开发者也会自行将webkit的库引入项目编译使用。不过虽然iOS7把它当成了标准库,可惜目前,我还没有在Apple Developer中找到像之前文章中收集的那样的官方文档介绍这个框架的具体使用方法。

好在还可以在Xcode中找到头文件,而且里面的注释对每个类和方法的功能写得还算清楚,再结合网上仅有的几篇文章的介绍,我也在此简单入门一下JavaScriptCore。更多细节还待开发过程中发现。
Read More →

2013-09-24
24 September
On September 24, 2013
In Knowledge Base(心得笔库), Language Tips(语言初试)

JavaScript取子串方法slice,substr,substring对比

在程序语言中,字符串可以说是最常用的一种类型,而在程序中对字符串的操作也是十分频繁。当程序语言自带多种字符串操作的方法时,用该语言编程程序时就有很多的便利性,提高开发的效率。但是当方法过多,甚至目的相似、参数雷同的时候,就容易造成迷惑难以选择的窘境。

在JavaScript中就有这样的情况出现,对于取字符串的子串的操作,JavaScript提供了三种不同的方法:slice,substr,substring。虽然在网上随便搜索一下,就可以找到介绍三者区别的文章,但是每次使用的时候,依然会迷糊无从选择。因此结合网上介绍的区别,在本文中将它们的异同之处罗列在表中,方便参照和区分。
Read More →

2013-08-31
31 August
On August 31, 2013
In Front Interface(界面构想), Language Tips(语言初试)

JavaScript操作SVG的一些知识

前阵子学习了一下SVG(Scalable Vector Graphics),希望能借此弥补自己在图形艺术上的不足,当然最后也没有得到什么提高,不过也扩充了一些网页前段技术知识。通过做了一些小的设计项目,也发现SVG可以弥补一些HTML元素的不足,比如倾斜、弧线、动画、复用等等。

虽然SVG和HTML一样都属于XML的一种方言,一些基本的JavaScript对HTML的DOM操作都适用于SVG,但是在实际运用中还是因为这样那样的细微区别遇到了不大不小的麻烦。所以通过此篇文章记录下遇到的问题和解决的方法。
Read More →

Posts pagination

Previous 1 … 7 8 9 … 11 Next
Facebook
Twitter
LinkedIn
RSS
ZhiHu

Recent Posts

  • AI Dev 26 x SF 体会
  • Google Pixel Phone 1 to 10
  • 三年居家工作感受
  • Pixel Watch智能手表和Pixel 5, 6 Pro 及 7 Pro手机
  • 我拥有过的无线耳机
  • 毕业工作一个月,我差点被开除
  • 我拥有过的移动硬盘

Categories

  • Algorithm Analysis(算法分析)
  • Article Collection(聚宝收藏)
  • Data Structures(数据结构)
  • Design Patterns(设计模式)
  • English Posts(英文写作)
  • Front Interface(界面构想)
  • IT Products(数码产品)
  • Knowledge Base(心得笔库)
  • Language Tips(语言初试)
  • Mathematical Theory(数学理论)
  • Mobile Development(移动开发)
  • Programming Life(程序人生)
  • Reading Notes(阅而后知)
  • Software Engineering(软件工程)
  • Special Tricks(奇技妙招)
  • Tangential Speech(漫话杂谈)

Tags

Aero Android API App Bash Binary Search Bitwise Operation Book C/C++ Career Chrome Conference CSS Debug Device DOM Extension Framework Game Google Gradle Hearthstone HTML Initialization Interview iOS Java JavaScript jQuery Keyword Language Issues Mac Microsoft Mobile Modifier Objective-C PHP Principle Reference Static String Tools Tutorial UI XML

Blogroll

  • Ahmed's Blog
  • Gert Lombard's Blog
  • Gordon Luk
  • Jack & Allison
  • 开发部落

Archives

Designed using Chromatic. Powered by WordPress.