Skip to content

Instantly share code, notes, and snippets.

@daohoangson
daohoangson / attachments.php
Last active September 26, 2015 06:10
internal_data file check
<?php
if (empty($argv[1])) {
die("\$argv[1] (\$backUpDir) is missing!\n");
}
$backUpDir = rtrim($argv[1], '/');
if (!is_dir($backUpDir)) {
die("{$backUpDir} is not a directory.");
}
#!/bin/sh
vi /etc/init.d/unoconvd
chmod 755 /etc/init.d/unoconvd
update-rc.d unoconvd defaults
service unoconvd start
@daohoangson
daohoangson / comments.js
Last active March 9, 2016 11:04
Export comments from a Facebook Page post.
var firstUrl = 'https://graph.facebook.com/v2.0/123/comments?access_token=xxx';
var process = require('process'),
request = require('request'),
JSONStream = require('JSONStream'),
es = require('event-stream');
var count = 0;
function get(url) {
request({url: url})
mysql> select thread_id, view_count from xf_thread where xf_thread.post_date > UNIX_TIMESTAMP(NOW()) - 365*2*86400 order by xf_thread.view_count desc limit 50;
+-----------+------------+
| thread_id | view_count |
+-----------+------------+
| 2468755 | 4214757 |
| 2316574 | 3792713 |
| 2292526 | 2449473 |
| 2360696 | 1438677 |
| 2389927 | 1429752 |
| 2382263 | 1172760 |
static class ParseTreeContext {
Context context;
List<AttachmentObj> attachments;
}
private static SpannableStringBuilder parseTree(JSONArray tree, ParseTreeContext ptc) throws JSONException {
SpannableStringBuilder builder = new SpannableStringBuilder();
for (int i = 0; i < tree.length(); i++) {
Object element = tree.get(i);
@daohoangson
daohoangson / mogrify.sh
Created October 14, 2016 02:58
Process (lots of) images with mogrify
#!/bin/bash
# Looks for all files under directory
# Then execute ImageMaick commands on them:
# 1. Strip metadata
# 2. Reduce quality to 66%
find /path/to/image/directory -type f -print0 | xargs -0 -n50 mogrify -strip -quality 66
<?php
$dupes = file('/tmp/similar.txt');
$images = array();
$basics = array();
$priorities = array('path' => array('/mnt/volume-sfo2-02/docker-rclone-data/Photos/' => 11));
$linesTotal = count($dupes);
$lineNo = filter_input(INPUT_GET, 'line_no', FILTER_VALIDATE_INT);
if ($lineNo <= 0) {

Keybase proof

I hereby claim:

  • I am daohoangson on github.
  • I am sondh (https://keybase.io/sondh) on keybase.
  • I have a public key whose fingerprint is 198E 3709 0052 0029 5F5F 9197 BB9A C34B 495C 0626

To claim this, I am signing this object:

@daohoangson
daohoangson / config.php
Last active August 23, 2017 04:37
Advanced usage of https://github.com/xfrocks/DevHelper docker dev env
<?php
$config['db']['host'] = 'mysql';
$config['db']['port'] = '3306';
$config['db']['username'] = 'root';
$config['db']['password'] = 'root';
$config['db']['dbname'] = 'xenforo';
if (preg_match('/^xenforo-(?<dbname>[a-z]+)\./', $_SERVER['SERVER_NAME'], $serverNameMatches)) {
$config['db']['dbname'] = $serverNameMatches['dbname'];