Skip to content

Instantly share code, notes, and snippets.

View darkcolonist's full-sized avatar
🐣
I rise from the fire, stronger and brighter.

Christian darkcolonist

🐣
I rise from the fire, stronger and brighter.
View GitHub Profile
@darkcolonist
darkcolonist / sequelize-output.json
Last active January 21, 2020 15:16
sequelize centralized model facade pattern
{
"conversations": [
{
"id": 1,
"title": "messenger dev",
"status": "active",
"created_by": 4,
"date_created": "2017-04-17T14:45:28.000Z",
"tbl_thread_users": [
{
@darkcolonist
darkcolonist / test.php
Last active April 6, 2017 09:43 — forked from anonymous/test.php
test
$result = $conn->query($sql);
if ($result->num_rows > 0) {
$showHeader = true;
$firstRow = $result->fetch_assoc();
if ( true === $showHeader ) { // to achieve a 'single header'
$showHeader = false; // avoid other headers
echo 'Receipt #: ' . $firstRow[0]['info'] . '<br><br>';
echo 'Table #: ' . $firstRow['tid'] . '<br>';
@darkcolonist
darkcolonist / export.sh
Last active March 2, 2017 07:28
mysql per-batch export to file migrate script
# @author: Christian Noel Reyes <[email protected]>
# @date: 2015-05-13
# @description: data / table-per table migration script.
# @caveats:
# source and target databases must have the same table structure for this script to work with no issues
# tested with mysql 5.1 (client)
# usage:
# bash export.sh --shost <source host> --sdb <source database> --suser <source username> --spass <source password>\
# --limit 10000;
@darkcolonist
darkcolonist / migrate.sh
Last active March 2, 2017 07:29
mysql per-batch export migrate script
# @author: Christian Noel Reyes <[email protected]>
# @date: 2015-05-13
# @description: data / table-per table migration script.
# @caveats:
# source and target databases must have the same table structure for this script to work with no issues
# tested with mysql 5.1 (client)
#
# usage:
# bash migrate.sh --shost <source host> --sdb <source database> --suser <source username> --spass <source password>\
# --thost <target host> --tdb <target database> --tuser <target username> --tpass <target password>\
@darkcolonist
darkcolonist / util_backtrace.php
Last active January 5, 2017 05:17
create code backtrace - list all files and lines passed through before the function
<?php
/**
* display backtrace of the code, and the list of files the code has
* passed through to reach this function.
*
* example:
* Array
* (
* [0] => /www/index.php:118
* [1] => /www/system/core/Bootstrap.php:55
@darkcolonist
darkcolonist / show-images.php
Created November 7, 2016 02:36
display all images inside a folder in a tabular format (php)
<?php
/**
* original source: http://stackoverflow.com/a/11903460/27698
*/
// $dirname = "media/images/iconized/";
$dirname = "./";
$images = glob("*.{jpg,png,gif}", GLOB_BRACE);
echo "<table>";
echo "<tr><th>source</th><th>image preview</th></tr>";
foreach($images as $image) {
@darkcolonist
darkcolonist / psvita-vpk-transfer-guide.md
Last active September 21, 2024 17:16
how to transfer VPK via FTP and install them in psvita (henkaku / vitashell)

#how to transfer games to your vita via FTP

###requirements

  • henkaku activated psvita 3.60
  • filezilla ftp client
  • wifi connection
  • make sure your psvita and computer are in the same wifi network

##in your computer

  • install filezilla (ftp client)
@darkcolonist
darkcolonist / url.php
Last active August 8, 2016 02:18
pretty url dissection
<?php echo "it works!" ?>
<!-- use this url: http://localhost/url.php/id/123/age/20/gender/male/context/something/scholar2 -->
<hr />
<?php
$actual_link = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
@darkcolonist
darkcolonist / cronjobs.sh
Last active July 27, 2016 06:42
display crontabs of all users then send as email (run as root)
#!/bin/bash
#List all cron jobs for all users
> cronjobs.sh.out
for user in `cat /etc/passwd | cut -d":" -f1`;
do
echo "# ===== crontabs of $user =====" >> cronjobs.sh.out;
crontab -l -u $user >> cronjobs.sh.out;
done
cat cronjobs.sh.out | mail -s "cronjobs list" [email protected]
rm cronjobs.sh.out
@darkcolonist
darkcolonist / filezilla-shortcut-howto.txt
Created July 12, 2016 08:26
how to create an instant filezilla shortcut
// nothing to do here, check the comments