Skip to content

Instantly share code, notes, and snippets.

#include <stdio.h>
#include <stdlib.h>
int main(int argc, const char * argv[])
{
int left, offset=0;
char *target = "daniel&vivid<daniel>,\"vivid\'";
char c, *dest;
const char *inp;
@TzuYangLin
TzuYangLin / main.m
Last active August 29, 2015 14:07
XCode: How to set a placeholder to UIAlertView's textField
UIAlertView *alert = .........
alert.alertViewStyle = UIAlertViewStylePlainTextInput;
alert.delegate = (id)self;
alert.tag = 0;
UITextField *textField = [alertView textFieldAtIndex:0];
textField.placeholder = @"Test";
@TzuYangLin
TzuYangLin / note.md
Last active August 29, 2015 14:07
Note: Close the Wi-Fi function at ASUS Router
@TzuYangLin
TzuYangLin / javascript.js
Last active August 29, 2015 14:07
Javascript: Check text format
// Function 1, return true or false.
(/^[a-zA-Z0-9\.\_\-]*$/g.test(document.getElementById("id").value)
// Function 2, return 0 is normal.
document.getElementById("id").value.search(/[^0-9_]/)
//Check Email Format, return 0 is error.
// Rules: 1. Just 1 '@'
// 2. At least one '.' in the URL and can't 1 by 1
// 3. No space
@TzuYangLin
TzuYangLin / javascript.js
Last active August 29, 2015 14:07
Javascript: Set the radio's init value
var multi_lang = document.form_lang.lang;
for (i=0; i<multi_lang.length; i++)
{
if (multi_lang[i].value == lang)
multi_lang[i].checked=true;
}
@TzuYangLin
TzuYangLin / javascript.js
Last active August 29, 2015 14:07
Javascript: Check the form element
function form_check_any_modity()
{
var form = document.forms[0];
for (var i=0; i<form.elements.length; i++)
{
var element = form.elements[i];
var type = element.type;
//alert("type="+type);
//alert("element.disabled="+element.disabled);
@TzuYangLin
TzuYangLin / javascript.js
Last active August 29, 2015 14:07
Function: Clean the char from string
function replace_text_rule(str)
{
str = str.replace(/</g, '');
str = str.replace(/>/g, '');
str = str.replace(/\"/g, '');
str = str.replace(/^\s+/, '');
return str;
}
@TzuYangLin
TzuYangLin / index.html
Last active August 29, 2015 14:07
Example: How to delete the option of select
<html>
<head>
<meta http-equiv=Content-Type content="text/html; charset=utf-8">
<script language="JavaScript">
function test()
{
var select = document.getElementById("test");
for(i=select.options.length-1;i>=0;i--)
{
select.remove(i);
@TzuYangLin
TzuYangLin / index.html
Last active August 29, 2015 14:07
Example: Call function in another frame
//Try:
<frameset col"50%,*">
<frame src="page1.htm">
<frame src="page2.htm" name="otherFrameName">
</frameset>
//Then in page1.htm:
<script language="JavaScript">
parent.otherFrameName.functionName();
</script>
@TzuYangLin
TzuYangLin / main.c
Last active August 29, 2015 14:07
Example: Get the Info from File
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/ioctl.h>
int main(int argc, const char * argv[])
{
FILE *fd;
char buf[96];