Skip to content

Instantly share code, notes, and snippets.

View nazt's full-sized avatar

Nat nazt

  • Chiang Mai Maker Club
  • Chiang Mai
  • X @nazt
View GitHub Profile
class CurrentCongestion {
String id
Date datatime
String congestionLevel
static mapping = {
table "chiangmai.current_congestion"
version false
columns {
id column: 'sensor_group_id', generator: 'assigned', type: 'string'
<?
require_once("/home/natz/twitter/lib/twitter.lib.php");
require_once('/home/natz/twitter/common.class.php');
$common=new Common();
$twitter=new Twitter($common->twitter->getUsername(),$common->twitter->getPassword());
$followers = $twitter->getFollowers();// array("cursor"=>-1)
try {
$xml = new SimpleXMLElement($followers);
} catch (Exception $e) {
#!/usr/bin/env ruby
require 'rubygems'
require 'twitter'
config = YAML::load(open(".twitter"))
httpauth = Twitter::HTTPAuth.new(config['email'], config['password'])
base = Twitter::Base.new(httpauth)
base.followers.each do |follower|
if !follower.following
def nekoParser = new org.cyberneko.html.parsers.SAXParser()
nekoParser.setFeature('http://xml.org/sax/features/namespaces', false)
/*nekoParser.setFeature('http://cyberneko.org/html/features/scanner/style/strip-comment-delims', true)
nekoParser.setFeature('http://cyberneko.org/html/features/scanner/script/strip-comment-delims', true) */
nekoParser.setFeature('http://cyberneko.org/html/features/scanner/ignore-specified-charset', true)
nekoParser.setProperty('http://cyberneko.org/html/properties/default-encoding',"TIS-620")
def page = new XmlSlurper(nekoParser).parse("http://www.google.co.th")
def links = page.depthFirst().grep{ it.name()=="IMG" && [email protected]().contains("something") }.'@src'
def today= new Date() //represents the date and time when it is created
println today
def tomorrow= today + 1,
dayAfter= today + 2,
yesterday= today - 1,
dayBefore= today - 2
println "\n$dayBefore\n$yesterday\n$today\n$tomorrow\n$dayAfter\n"
assert today + 7 == today.plus(7) && today - 15 == today.minus(15)
def nekoParser = new org.cyberneko.html.parsers.SAXParser()
nekoParser.setFeature('http://xml.org/sax/features/namespaces', false)
nekoParser.setFeature('http://cyberneko.org/html/features/scanner/ignore-specified-charset', true)
nekoParser.setProperty('http://cyberneko.org/html/properties/default-encoding',"TIS-620")
url="http://view.gprocurement.go.th/01_procure_egp/index.php?page=1"
page = new XmlSlurper(nekoParser).parse(url)
links = page.depthFirst().grep{ it.name() == 'A' && [email protected]().contains("id") }
def nekoParser = new org.cyberneko.html.parsers.SAXParser()
nekoParser.setFeature('http://xml.org/sax/features/namespaces', false)
nekoParser.setFeature('http://cyberneko.org/html/features/scanner/ignore-specified-charset', true)
nekoParser.setProperty('http://cyberneko.org/html/properties/default-encoding',"TIS-620")
url="http://view.gprocurement.go.th/01_procure_egp/index.php?page=1"
page = new XmlSlurper(nekoParser).parse(url)
links = page.depthFirst().grep{ it.name() == 'A' && [email protected]().contains("id") }
<?php
header('Content-type: text/html; charset=windows-874');
require 'simple_html_dom.php';
$file = $_FILES['userfile'];
$allowedExtensions = array("txt", "htm", "html");
function isAllowedExtension($fileName) {
global $allowedExtensions;
Apr 23, 2010 6:25:59 AM org.apache.catalina.core.ApplicationContext log
INFO: HTMLManager: init: Associated with Deployer 'Catalina:type=Deployer,host=localhost'
Apr 23, 2010 6:25:59 AM org.apache.catalina.core.ApplicationContext log
INFO: HTMLManager: init: Global resources are available
Apr 23, 2010 6:25:59 AM org.apache.catalina.core.ApplicationContext log
INFO: HTMLManager: list: Listing contexts for virtual host 'localhost'
Apr 23, 2010 6:30:53 AM org.apache.catalina.core.ApplicationContext log
INFO: HTMLManager: list: Listing contexts for virtual host 'localhost'
Apr 23, 2010 6:31:46 AM org.apache.catalina.core.ApplicationContext log
INFO: HTMLManager: install: Installing web application from '/home/natz/TraffyAds-1.1.war'
// Licensed to the Apache Software Foundation (ASF) under one or more
// contributor license agreements. See the NOTICE file distributed with
// this work for additional information regarding copyright ownership.
// The ASF licenses this file to You under the Apache License, Version 2.0
// (the "License"); you may not use this file except in compliance with
// the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software