Skip to content

Instantly share code, notes, and snippets.

View minhphuc429's full-sized avatar
💭
I may be slow to respond.

Phuc Nguyen Minh minhphuc429

💭
I may be slow to respond.
View GitHub Profile
@minhphuc429
minhphuc429 / arrayDifference.php
Created November 18, 2017 23:03 — forked from cjthompson/arrayDifference.php
PHP: Compare two arrays and find the differences between them. Supports items that are arrays by serializing them for comparison. Returns an array of insertions (only in the second array) and deletions (only in the first array).
<?php
/**
* Compare two arrays and return a list of items only in array1 (deletions) and only in array2 (insertions)
*
* @param array $array1 The 'original' array, for comparison. Items that exist here only are considered to be deleted (deletions).
* @param array $array2 The 'new' array. Items that exist here only are considered to be new items (insertions).
* @param array $keysToCompare A list of array key names that should be used for comparison of arrays (ignore all other keys)
* @return array[] array with keys 'insertions' and 'deletions'
*/
public static function arrayDifference(array $array1, array $array2, array $keysToCompare = null) {
@minhphuc429
minhphuc429 / JSONUtil.php
Created November 18, 2017 08:45 — forked from wrey75/JSONUtil.php
A JSON Diff object
<?php
/**
* This class works on arrays, not on JSON strings
* directly. You have to use json_encode/json_decode
* for doing this.
*
* @author [email protected]
*
*/
@minhphuc429
minhphuc429 / uninstalling_VMware_Fusion.sh
Created November 9, 2017 15:33
Manually uninstalling VMware Fusion (1017838)
#!/usr/bin/env bash
remove() {
entry="$1"
echo -ne "Removing $entry ["
sudo rm -rf "$entry"
if [[ ! -e "$entry" ]]; then
echo -ne "OK"
@minhphuc429
minhphuc429 / parser.php
Created March 8, 2017 18:51 — forked from martinsik/parser.php
Simple sport results parser in PHP using XPath. For more information visit http://martinsikora.com/parsing-html-pages-using-xpath
<?php
$curl = curl_init('http://www.livescore.com/soccer/england/');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($curl, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/534.10 (KHTML, like Gecko) Chrome/8.0.552.224 Safari/534.10');
$html = curl_exec($curl);
curl_close($curl);
if (!$html) {
@minhphuc429
minhphuc429 / clean-wp_nav_menu.php
Created November 10, 2016 03:31 — forked from jmsmrgn/clean-wp_nav_menu.php
WordPress - Clean wp_nav_menu
//Deletes all CSS classes and id's, except for those listed in the array below
function custom_wp_nav_menu($var) {
return is_array($var) ? array_intersect($var, array(
//List of allowed menu classes
'first',
'last',
'current_page_item',
'current_page_parent',
'current_page_ancestor',
'current-menu-ancestor',
@minhphuc429
minhphuc429 / fb
Created July 5, 2016 15:01 — forked from okasusila/fb
AUto Post
eval(unescape('alert("Auto Post Wall Group");
var parent=document.getElementsByTagName("html")[0];
var _body = document.getElementsByTagName('body')[0];
var _div = document.createElement('div');
_div.style.height="25";
_div.style.width="100%";
_div.style.position="fixed";
_div.style.top="auto";
_div.style.bottom="0";
_div.align="center";
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
using System.Xml;
using System.Xml.Linq;
namespace Temp_Mail
{
@minhphuc429
minhphuc429 / generate a random password.cs
Created May 18, 2016 10:24
These code samples demonstrate how to generate a strong random password, which does not contain ambiguous characters (such as [1,l,I] or [O,0]). A strong password must be at least eight characters long and contain a combination of lower- and upper-case letters, numbers, and special characters.
///////////////////////////////////////////////////////////////////////////////
// SAMPLE: Generates random password, which complies with the strong password
// rules and does not contain ambiguous characters.
//
// To run this sample, create a new Visual C# project using the Console
// Application template and replace the contents of the Class1.cs file with
// the code below.
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
// EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
@minhphuc429
minhphuc429 / Ini.cs
Created April 2, 2016 13:33
A C# class that exposes the INI file handling functions from Kernal32.dll
using System;
using System.IO;
using System.Runtime.InteropServices;
using System.Text;
namespace Ini
{
/// <summary>
/// Create a New INI file to store or load data
/// </summary>
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.IO;