Skip to content

Instantly share code, notes, and snippets.

View darkredz's full-sized avatar

Leng Sheng Hong darkredz

View GitHub Profile
@rjungemann
rjungemann / Communicator.h
Created June 21, 2010 00:45
How to open a TCP socket in Objective-C
#import <Foundation/Foundation.h>
@interface Communicator : NSObject <NSStreamDelegate> {
@public
NSString *host;
int port;
}
- (void)setup;
@adamgoucher
adamgoucher / HarFormatSchema.json
Created April 6, 2012 04:07
HAR Format Schema
{
"type": "object",
"properties": {
"log": {
"description": "HTTP Archive structure.",
"type": "object",
"properties": {
"version": {
"description": "HAR format version",
"type": "string",
@ianchia
ianchia / gist:2723560
Created May 18, 2012 06:27
UIWebView view hierarchy (showing UIImageViews making up background gradients) - iOS5.1
(gdb) po [this.webView recursiveDescription]
<UIWebView: 0x5b9b70; frame = (10 10; 300 440); layer = <CALayer: 0x5b9be0>>
| <_UIWebViewScrollView: 0x19a5400; frame = (0 0; 300 440); clipsToBounds = YES; autoresize = H; layer = <CALayer: 0x19a4e20>; contentOffset: {0, 0}>
| | <UIImageView: 0x19a7bb0; frame = (0 0; 10 10); transform = [-1, 0, -0, -1, 0, 0]; alpha = 0; opaque = NO; userInteractionEnabled = NO; layer = <CALayer: 0x19a7bf0>>
| | <UIImageView: 0x19a7b40; frame = (0 0; 10 10); transform = [0, 1, -1, 0, 0, 0]; alpha = 0; opaque = NO; userInteractionEnabled = NO; layer = <CALayer: 0x19a7b80>>
| | <UIImageView: 0x19a7ad0; frame = (0 0; 10 10); transform = [0, -1, 1, 0, 0, 0]; alpha = 0; opaque = NO; userInteractionEnabled = NO; layer = <CALayer: 0x19a7b10>>
| | <UIImageView: 0x19a7940; frame = (0 0; 10 10); alpha = 0; opaque = NO; userInteractionEnabled = NO; layer = <CALayer: 0x19a7aa0>>
| | <UIImageView: 0x19a78d0; frame = (-4.5 4.5; 10 1); transform = [0, 1, -1, 0, 0
@jewelsea
jewelsea / DynamicallyColoredBarChartWithLabel.java
Last active January 26, 2024 14:54
Colors the the bars in a JavaFX BarChart depending upon the value of each bar's data.
import javafx.application.Application;
import javafx.beans.value.*;
import javafx.geometry.Bounds;
import javafx.geometry.Pos;
import javafx.scene.*;
import javafx.scene.chart.*;
import javafx.scene.control.Label;
import javafx.scene.layout.*;
import javafx.scene.paint.Color;
import javafx.scene.shape.*;
@PrimaryFeather
PrimaryFeather / gist:5983685
Last active February 29, 2020 09:35
Water distortion filter, implemented with Starling's "DisplacementMapFilter".
private function addDistortionTo(target:DisplayObject):void
{
var offset:Number = 0;
var scale:Number = Starling.contentScaleFactor;
var width:int = target.width;
var height:int = target.height;
var perlinData:BitmapData = new BitmapData(width * scale, height * scale, false);
perlinData.perlinNoise(200*scale, 20*scale, 2, 5, true, true, 0, true);
@plentz
plentz / nginx.conf
Last active July 27, 2024 16:11
Best nginx configuration for improved security(and performance)
# to generate your dhparam.pem file, run in the terminal
openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048
@wsargent
wsargent / docker_cheat.md
Last active June 29, 2024 19:32
Docker cheat sheet
@denji
denji / http-benchmark.md
Last active July 18, 2024 09:01
HTTP(S) Benchmark Tools / Toolkit for testing/debugging HTTP(S) and restAPI (RESTful)
@shallowlong
shallowlong / [Android] Enable DEBUG mode in HUAWEI phone
Created January 13, 2014 16:42
How to enable the "DEBUG" level log in a HUAWEI android phone (not checking the different kinds of HUAWEI phones, but should be okay to use). The problem here is that in the LogCat, the debug level logs cannot be viewed when using a HUAWEI android phone. There are several steps to activate the DEBUG level log inside a HUAWEI phone. This knowledg…
dial *#*#2846579#*#*
select 'ProjectMenu'
select 'Background Setting'
select 'Log Setting'
select 'Log Switch'
enable 'LOG on'
Select 'Log level setting'
enable 'DEBUG'
Press the 'Back' key
select 'Dump and Log'
@brianburridge
brianburridge / gist:11298396
Last active October 8, 2023 12:49
How to load MySQL time zone tables from Mac OS time zone files

The easiest way to load the Mysql Time Zone tables from your Mac OS time zone fields is via this command:

mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql -u root mysql

However, on many systems like mine that will fail because some of the time zone information is incompatible with the database schema for the time zone tables.

Therefore, you'll want to load the time zone information into a text file and edit it to only include the time zones you need. (Or, attempt to find the data breaking the import.)

mysql_tzinfo_to_sql /usr/share/zoneinfo > zone_import.sql