Skip to content

Instantly share code, notes, and snippets.

View chaintng's full-sized avatar

Chainarong Tangsurakit chaintng

View GitHub Profile
SELECT path_overlap_id, overlap_geom, ST_Length(overlap_geom::geography) overlap_length, (ST_Length(overlap_geom::geography)/compare_length)*100 as overlap_percent
FROM (
SELECT po.path_overlap_id,
CASE WHEN po.bus_sub_path_id IS NULL AND po.other_sub_path_id IS NULL THEN
-- WHEN INTERSECT BUS AND BUS
ST_AsText(ST_LineMerge(ST_CollectionExtract(
ST_Intersection(ST_Buffer(
CASE po.path_section WHEN 'D' THEN ST_SetSRID(bp_a.geom_diff, 4326)
ELSE ST_SetSRID(bp_a.geom, 4326)
END
@chaintng
chaintng / test.cs
Last active September 17, 2015 03:05
CreateUserUnique
public UserUnique CreateUserUniqueIfNotExisted(CustomerInsight_DBEntities refDb, Dictionary<int, UserUnique> existedUserUnique)
{
UserUnique tmpUu;
if (!existedUserUnique.TryGetValue(this.user_unique_id, out tmpUu))
{
tmpUu = UserUnique.CreateUserUniqueFromUui(this.user_unique_id, refDb);
existedUserUnique.Add(tmpUu.user_unique_id, tmpUu);
}
return tmpUu;
}
@chaintng
chaintng / SearchHotelPriceRequest-request.xml
Last active June 17, 2016 02:04
2016-06-09T10:05:44.000Z
<?xml version="1.0" encoding="utf-8"?>
<Request>
<Source>
<RequestorID Client="15858" EMailAddress="XML@HOTELQUICKLY.COM" Password="2KS0JPZT5O"/>
<RequestorPreferences Currency="USD" Country="TW">
<RequestMode>SYNCHRONOUS</RequestMode>
</RequestorPreferences>
</Source>
<RequestDetails>
<SearchHotelPriceRequest>
@chaintng
chaintng / pokedex-jquery-1.js
Last active August 19, 2016 10:49
pokedex-jquery-1
// 1. set Listener for each filter
$("#pokemonTypeFilter").on('change', function(){
var filterPokemonType = this.value;
var filterPokemonAtk = $("#pokemonAtkFilter").val();
var filterPokemon = filterPokemonByTypeAndMinAtk(allPokemons, filterPokemonType, filterPokemonAtk);
renderPokemonList(filterPokemon);
});
$("#pokemonAtkFilter").on('keyup', function(){
var filterPokemonAtk = this.value;
@chaintng
chaintng / pokedex-jquery-2.js
Created July 23, 2016 10:21
pokedex-jquery-2.js
// 2. set render function
var renderPokemonList = function(filterPokemon) {
$("#filterPokemonCount").html(filterPokemon.length);
var liStrings = filterPokemon.map(function (item) {
return "<li>" + item.name + " (Atk: " + item.attack + ", Def: " + item.defense + ")</li>";
});
$("#pokemonListUl").html(liStrings);
}
@chaintng
chaintng / pokedex-react-1.js
Last active August 19, 2016 10:54
pokedex-react-1.js
// 1. set Reducer function to accept store.dispatch()
var reducer = function (state, action) {
var newState = state;
if (typeof state === 'undefined') {
return {
pokemonType: null,
pokemonAtk: null
};
}
switch (action.type) {
@chaintng
chaintng / pokedex-react-2.js
Last active August 19, 2016 10:54
pokedex-react-2.js
// 3. set render function
var render = function() {
var filterPokemonType = store.getState().pokemonType;
var filterPokemonAtk = store.getState().pokemonAtk;
var filterPokemon = filterPokemonByTypeAndMinAtk(allPokemons, filterPokemonType, filterPokemonAtk);
ReactDOM.render(
<div>
<div>--- Total Filter Pokemon: {filterPokemon.length} ---</div>
<ul>
@chaintng
chaintng / pokemonComponent.js
Created July 23, 2016 11:52
pokemonComponent.js
return <PokemonInfo pokemonDetail={item} />
@chaintng
chaintng / react-step-1.jsx
Last active October 16, 2016 04:12
react-step-1.jsx
var Result = React.createClass({
render: function() {
return (<div>
<div>--- Total Filter Pokemon: {this.props.filterPokemon.length} ---</div>
<ul>
<li></li> {/* how each pokemon display */}
</ul>
</div>);
}
});
@chaintng
chaintng / react-step-2-1.jsx
Last active October 16, 2016 04:20
react-step-2.jsx
var Pokedex = React.createClass({
getInitialState: function() { // 1) Setup initial state
return {
filterPokemonType: null,
filterPokemonAtk: null,
};
},
filterPokemonByTypeAndMinAtk: function (allPokemons, filterPokemonType, filterPokemonAtk) {
// ... Filter function just like in jQuery
},