Skip to content

Instantly share code, notes, and snippets.

View henrybear327's full-sized avatar

Chun-Hung Tseng henrybear327

View GitHub Profile
<?php
function get_ip_address() {
$ip_keys = array('HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP', 'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR');
foreach ($ip_keys as $key) {
if (array_key_exists($key, $_SERVER) === true) {
foreach (explode(',', $_SERVER[$key]) as $ip) {
// trim for safety measures
$ip = trim($ip);
// attempt to validate IP
if (validate_ip($ip)) {
#include <Wire.h>
byte i2cdata[4];
void setup() {
Wire.begin();
Serial.begin(9600);
}
void loop() {
@henrybear327
henrybear327 / Banking.c
Last active August 29, 2015 14:22
Banking.c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct node_staff {
char name[50];
char password[50];
struct node_staff *next;
};
struct node_staff *
read_staff(struct node_staff *last); //回傳first的位址,這樣在main裡才能用
@henrybear327
henrybear327 / R3W1D.c
Last active August 29, 2015 14:21
R3W1D.c
#include <stdio.h>
#include <stdlib.h>
struct x {
long long left;
long long right;
};
int cmp(const void *a, const void *b)
{
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct data {
int front;
int back;
} all[50000];
int cmp(const void *a, const void *b)
@henrybear327
henrybear327 / ITSA Problem 3(by 陳丕佑).c
Created April 8, 2015 14:24
ITSA Problem 3(by 陳丕佑).c
#include <cstdio>
#include <iostream>
#include <cstring>
using namespace std;
int main()
{
int N;
int ans[100][100]= {0};
cin >> N;
@henrybear327
henrybear327 / ITSA Problem 4.c
Created April 8, 2015 14:20
ITSA Problem 4.c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void walk_through(int row, int column);
int size, input[20][20];
char output[20][20];
int flag = 0;
@henrybear327
henrybear327 / ITSA problem 2.c
Last active August 29, 2015 14:18
ITSA problem 2.c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
while(1) {
int data[3][3];
for(int i = 0; i < 3; i++) {
for(int j = 0; j < 3; j++) {
@henrybear327
henrybear327 / ITSA Problem 5.c
Created April 8, 2015 10:34
ITSA Problem 5.c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
int main()
{
int cases;
while(scanf("%d", &cases) != EOF) {
while(cases--) {
@henrybear327
henrybear327 / ITSA problem 1.c
Created April 8, 2015 10:14
ITSA problem 1.c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
int input;
while(scanf("%d", &input) != EOF) {
double answer = (double) input * 1.6;
printf("%.1f\n", answer);