Skip to content

Instantly share code, notes, and snippets.

View stiucsib86's full-sized avatar

binghan.eth stiucsib86

View GitHub Profile
@stiucsib86
stiucsib86 / gist:4248353
Created December 10, 2012 04:16
Github Markdown - Table of Content (example)

Table of Content

  • [What is Lorem Ipsum](#wiki-What is Lorem Ipsum)
  • [Where does it come from](#wiki-Where does it come from)
  • [Why do we use it](#wiki-Why do we use it)
  • [Where can I get some](#wiki-Where can I get some)

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.

@stiucsib86
stiucsib86 / gist:6150321
Created August 4, 2013 13:31
[Google Maps v3] Get Rectangle area with computeArea
var _computeRectangleArea = function(bounds) {
if (!bounds) {
return 0;
}
var sw = bounds.getSouthWest();
var ne = bounds.getNorthEast();
var southWest = new google.maps.LatLng(sw.lat(), sw.lng());
var northEast = new google.maps.LatLng(ne.lat(), ne.lng());
var southEast = new google.maps.LatLng(sw.lat(), ne.lng());
var northWest = new google.maps.LatLng(ne.lat(), sw.lng());
@stiucsib86
stiucsib86 / gist:6337248
Last active February 16, 2018 23:45
Android ChatHead Service
public class ChatHeadService extends Service {
private WindowManager windowManager;
private List<View> chatHeads;
private LayoutInflater inflater;
@Override
public IBinder onBind(Intent intent) {
return null;
}
@stiucsib86
stiucsib86 / gist:6337261
Last active December 21, 2015 16:59
ChatHead XML
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:id="@+id/txt_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
@stiucsib86
stiucsib86 / gist:6710147
Created September 26, 2013 05:20
Simple ping test for cross-domain request.
<?php
header("Content-Type: application/json");
// Allow Credentials
header('Access-Control-Allow-Credentials: true');
// Allow all origins
if (isset($_SERVER['HTTP_REFERER']) || isset($_SERVER['HTTP_ORIGIN'])) {
if (isset($_SERVER['HTTP_REFERER'])) {
@stiucsib86
stiucsib86 / gist:6759304
Last active December 24, 2015 06:49
Azure Website for PHP web.config file
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<!--
Removing index.php from URLs
-->
<rules>
<rule name="Imported Rule 1" stopProcessing="true">
<match url="^(.*)$" ignoreCase="false" />
@stiucsib86
stiucsib86 / gist:6759495
Last active June 20, 2021 02:27
PHP test file for CORS testing.
<?php
header("Content-Type: application/json");
// Allow Credentials
header('Access-Control-Allow-Credentials: true');
// Allow all origins
if (isset($_SERVER['HTTP_REFERER']) || isset($_SERVER['HTTP_ORIGIN'])) {
if (isset($_SERVER['HTTP_REFERER'])) {
@stiucsib86
stiucsib86 / open-graph-protocol.php
Created January 15, 2014 16:48
Facebook Wordpress plugin temporary fix. This fixes issue where https://www.facebook.com/sharer/sharer.php throws "The message could not be posted to this Wall." when there are multiple "og:image" meta tag.
/**
* Identify image attachments related to the post.
*
* Request the full size of the attachment, not necessarily the same as the size used in the post.
*
* @since 1.5
*
* @param stdClass|WP_Post $post WordPress post of interest
* @return array {
@stiucsib86
stiucsib86 / gist:ebff282a3989f9a24117
Created August 3, 2014 14:44
Backup MySQL dump to Azure Storage
#!/bin/sh
mkdir /home/bitnami/backups/
export BACKUP_FILE=/home/bitnami/backups/db-backup.sql.gz
export DATABASE_SCHEMA_NAME=--all-databases
export AZURE_CONTAINER=YOUR_VALUE_HERE
export AZURE_NAME=YOUR_VALUE_HERE
export AZURE_KEY=YOUR_VALUE_HERE
export AZURE_BLOB_NAME=db-production-$(date +%Y%m%d%H%M%S).sql.gz
@stiucsib86
stiucsib86 / composer-view.js
Created February 6, 2017 03:44
Visual Composer fixes "html2element" and "render" fixes
html2element:function (html) {
var attributes = {},
$template;
if (_.isString(html)) {
this.template = _.template(html);
} else {
try {
this.template = _.template(html());
} catch (err) {
this.template = html;