Skip to content

Instantly share code, notes, and snippets.

View daltonnyx's full-sized avatar
🦥

Quy Truong daltonnyx

🦥
  • Saigon Technology
  • Da Nang
View GitHub Profile
@daltonnyx
daltonnyx / ftp_auth_error.md
Created September 16, 2017 08:11
Error when create ftp user via pure-pw useradd

I've just had a similar problem. I've added user using pure-pw useradd and get 530 Login authentication failed.

The solution was a symlink added to /etc/pure-ftpd/auth directory pointing to /etc/pure-ftpd/conf/PureDB (there is a path to file that keeps ftp users) that shows in alphabetical order before other files in auth, e.g.

cd cd /etc/pure-ftpd/auth/ ln -s ../conf/PureDB 50PureDB then ls returns:

50PureDB -> ../conf/PureDB 65unix -> ../conf/UnixAuthentication

If you haven't solved this yet, I have a solution that worked for me. I'm on CentOS 7.x but it should still work for you, and anyone else wanting to use pecl-memcache with PHP 7 (not pecl-memcached as that's a completely different package).
As you have already discovered, you must use the Memcache PHP 7 port on GitHub for this.
Login to your shell and perform the following:
1. wget https://github.com/websupport-sk/pecl-memcache/archive/NON_BLOCKING_IO_php7.zip
2. unzip NON_BLOCKING_IO_php7.zip
3. cd pecl-memcache-NON_BLOCKING_IO_php7
4. /opt/cpanel/ea-php70/root/usr/bin/phpize && ./configure --enable-memcache --with-php-config=/opt/cpanel/ea-php70/root/usr/bin/php-config && make
# awk '{if(NR==1)sub(/^\xef\xbb\xbf/,"");print}' text.txt
Source: http://stackoverflow.com/questions/1068650/using-awk-to-remove-the-byte-order-mark
Updated: (Suggested by Van Overveldt Peter)
# tail --bytes=+4 text.txt
<?php
add_filter('template', 'change_theme');
add_filter('option_template', 'change_theme');
add_filter('option_stylesheet', 'change_theme');
function change_theme()
{
require_once("/path/to/Mobile_Detect.php");
$detect = new Mobile_Detect;
@daltonnyx
daltonnyx / example.html
Created June 29, 2017 18:32
jQuery quyDowndown
<div class="dropdown-select">
<span class="placeholder">--Chọn nhóm--</span>
<ul class="dropdown nhom-multiple">
<li class="level-1">
<span class="group-caption">
<input type="checkbox" value="15" class="group-checkbox"> Trung tâm Điều hành thông tin</span>
<ul class="sub-option">
<li class="level-2">
<span class="group-caption"><input type="checkbox" value="84" class="group-checkbox"> Đài OMC</span>

Creating a bootable Ubuntu USB flash drive from terminal

Place the ubuntu.iso file in any hard disk partition. Then mount the ubuntu.iso file with the below commands in terminal:

sudo mkdir /media/iso/ sudo mount -o loop /path/to/ubuntu.iso /media/iso

Insert your USB flash drive. My drive is /dev/sdd.

/*
* Handle multi domain into single instance of wordpress installation
*/
define('WP_SITEURL', 'http://' . $_SERVER['HTTP_HOST']);
define('WP_HOME', 'http://' . $_SERVER['HTTP_HOST']);
//Here's a non-jQuery version:
function toQueryString(obj) {
var parts = [];
for (var i in obj) {
if (obj.hasOwnProperty(i)) {
parts.push(encodeURIComponent(i) + "=" + encodeURIComponent(obj[i]));
}
}
return parts.join("&");
@daltonnyx
daltonnyx / .tern-project
Created June 18, 2017 18:54 — forked from nisaacson/.tern-project
Use tern with vim for node.js development.
{
"libs": [
"browser",
"underscore",
"jquery"
],
"plugins": {
"node": {}
}
}
var lastScrollTop = 0;
// element should be replaced with the actual target element on which you have applied scroll, use window in case of no target element.
element.addEventListener("scroll", function(){ // or window.addEventListener("scroll"....
var st = window.pageYOffset || document.documentElement.scrollTop; // Credits: "https://github.com/qeremy/so/blob/master/so.dom.js#L426"
if (st > lastScrollTop){
// downscroll code
} else {
// upscroll code
}
lastScrollTop = st;