Skip to content

Instantly share code, notes, and snippets.


Lee Xun LeeXun

View GitHub Profile
View 1_two_sum_leetcode.c
* Note: The returned array must be malloced, assume caller calls free().
int* twoSum(int* nums, int numsSize, int target) {
int i, j;
int *ans = malloc(sizeof(int)*2);
for(i=0; i<numsSize; i++) {
for(j=0; j<numsSize; j++) {
if(nums[i]+nums[j] == target && i != j) {
ans[0] = j;
View postgres_queries_and_commands.sql
-- show running queries (pre 9.2)
SELECT procpid, age(query_start, clock_timestamp()), usename, current_query
FROM pg_stat_activity
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- show running queries (9.2)
SELECT pid, age(query_start, clock_timestamp()), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'
View example.php
->leftJoin('likes', function($join) use ($viewer_id) {
$join->on('likes.customer_id', '=', DB::raw($viewer_id));
$join->on('likes.like_type', '=', DB::raw(Like::LIKE_TYPE_PRODUCT));
$join->on('likes.like_id', '=', 'oc_product.product_id');
View two-way-binding-simple.html
<!DOCTYPE html>
<html lang="en">
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Two way binding</title>
#app {
width: 100%;
View isSubstring.js
module.exports = function isSubstring(a, b) {
let i = 0
while(i < a.length - b.length){
let j = 1
if(a[i] == b[0]){
if(a[i+j] == b[j]){
if(j == b.length - 1){
return i + j
View messenger-sitcker-changer.js
* 2017/10/31 Happy Helloween
* Author: LeeXun
* Just copy and paste it on console
* Notice: It's really dangerous if you don't know that this means!
function handleNewElement() {
var nodeList = document.getElementById('js_1').querySelectorAll("[aria-label='貼圖']");
var s = nodeList[nodeList.length-1].style;
LeeXun / hopscotch.c
Last active Oct 27, 2017
NCCU Assignment 4: Modified "hopscotch" game
View hopscotch.c
#include <stdio.h>
#include <stdlib.h>
#define DATA_SIZE_LIMIT 30
# how to compile and execute:
# gcc hopscotch.c -o hopscotch
# ./hopscotch < input.txt
We couldn’t find that file to show.
LeeXun / gist:f068e5411a57aed6153f3f349bafefe0
Created Jul 21, 2016 — forked from prime31/gist:5675017
Simple PHP script showing how to send an Android push notification. Be sure to replace the API_ACCESS_KEY with a proper one from the Google API's Console page. To use the script, just call scriptName.php?id=THE_DEVICE_REGISTRATION_ID
View gist:f068e5411a57aed6153f3f349bafefe0
// API access key from Google API's Console
$registrationIds = array( $_GET['id'] );
// prep the bundle
$msg = array
You can’t perform that action at this time.