Git Flow Command
To list/start/finish feature branches, use:
git flow feature
git flow feature start [name] [base]
git flow feature finish [name]
To push/pull a feature branch to the remote repository, use:
git flow feature publish [name]
git flow feature pull [remote] [name]
To list/start/finish release branches, use:
git flow release
git flow release start [release] [base]
git flow release finish [release]
To list/start/finish hotfix branches, use:
git flow hotfix
git flow hotfix start [release] []
git flow hotfix finish [release]
To list/start support branches, use:
git flow support
git flow support start [release] [base]
Source: https://github.com/nvie/gitflow
Git change remote URL
git remote -v
# View existing remotes
# origin https://github.com/user/repo.git (fetch)
# origin https://github.com/user/repo.git (push)
git remote set-url origin https://github.com/user/repo2.git
# Change the 'origin' remote's URL
git remote -v
# Verify new remote URL
# origin https://github.com/user/repo2.git (fetch)
# origin https://github.com/user/repo2.git (push)
PHP command line syntax checking
Thanks to this bro for the post that help me find the syntax error inside my bunch of php code (http://www.electrictoolbox.com/php-command-line-syntax-checking/)
Syntax checking a single PHP file from the command line
The syntax for checking is like this, where the -l flag is a lower case L:
php -l filename
Syntax check all PHP files in the current directory
for i in *.php; do php -l $i; done
Syntax check all PHP files in the current directory and all subdirectories
find . -name \*.php -exec php -l "{}" \;
Add Currency to Woocommerce
Add this code to your functions.php file:
function add_my_currency( $currencies ) {
$currencies["IDR"] = 'Rupiah';
return $currencies;
}
add_filter( 'woocommerce_currencies', 'add_my_currency', 10, 1 );
Access Remote file share with username and password in C#
If you want to access a network sharing folder, you can use this class to provide username and password.
using System;
using System.Runtime.InteropServices;
using BOOL = System.Boolean;
using DWORD = System.UInt32;
using LPWSTR = System.String;
using NET_API_STATUS = System.UInt32;
namespace CommonFunctions
{
public class UNCAccess
{
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
internal struct USE_INFO_2
{
internal LPWSTR ui2_local;
internal LPWSTR ui2_remote;
internal LPWSTR ui2_password;
internal DWORD ui2_status;
internal DWORD ui2_asg_type;
internal DWORD ui2_refcount;
internal DWORD ui2_usecount;
internal LPWSTR ui2_username;
internal LPWSTR ui2_domainname;
}
[DllImport("NetApi32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
internal static extern NET_API_STATUS NetUseAdd(
LPWSTR UncServerName,
DWORD Level,
ref USE_INFO_2 Buf,
out DWORD ParmError);
[DllImport("NetApi32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
internal static extern NET_API_STATUS NetUseDel(
LPWSTR UncServerName,
LPWSTR UseName,
DWORD ForceCond);
private string sUNCPath;
private string sUser;
private string sPassword;
private string sDomain;
private int iLastError;
public UNCAccess()
{
}
public UNCAccess(string UNCPath, string User, string Domain, string Password)
{
login(UNCPath, User, Domain, Password);
}
public int LastError
{
get { return iLastError; }
}
///
///
/// UNC share path
/// Username
/// Domain
/// Password
/// True if login was successful
public bool login(string UNCPath, string User, string Domain, string Password)
{
sUNCPath = UNCPath;
sUser = User;
sPassword = Password;
sDomain = Domain;
return NetUseWithCredentials();
}
private bool NetUseWithCredentials()
{
uint returncode;
try
{
USE_INFO_2 useinfo = new USE_INFO_2();
useinfo.ui2_remote = sUNCPath;
useinfo.ui2_username = sUser;
useinfo.ui2_domainname = sDomain;
useinfo.ui2_password = sPassword;
useinfo.ui2_asg_type = 0;
useinfo.ui2_usecount = 1;
uint paramErrorIndex;
returncode = NetUseAdd(null, 2, ref useinfo, out paramErrorIndex);
iLastError = (int)returncode;
return returncode == 0;
}
catch
{
iLastError = Marshal.GetLastWin32Error();
return false;
}
}
///
///
/// True if closing was successful
public bool NetUseDelete()
{
uint returncode;
try
{
returncode = NetUseDel(null, sUNCPath, 2);
iLastError = (int)returncode;
return (returncode == 0);
}
catch
{
iLastError = Marshal.GetLastWin32Error();
return false;
}
}
}
}
Before you get the file, you should do this:
UNCAccess unc = new UNCAccess(@"\\host\share", "username", "domain", "password");
Add Watermark to Textbox using jQuery
jQuery(document).ready(function() {
var watermark = "Type the code seen above";
jQuery(".wpcf7-captchar").val(watermark);
jQuery(".wpcf7-captchar").focus(function() {
if (jQuery.trim(jQuery(".wpcf7-captchar").val()) == watermark) {
jQuery(".wpcf7-captchar").val("");
}
});
jQuery(".wpcf7-captchar").blur(function() {
if (jQuery.trim(jQuery(".wpcf7-captchar").val()) == "") {
jQuery(".wpcf7-captchar").val(watermark);
}
});
});
Contact Form 7 watermark for select menu
Put this code in your functions.php file:
function my_wpcf7_form_elements($html) {
$text = 'Please select...';
$html = str_replace('---', '' . $text . '', $html);
return $html;
}
add_filter('wpcf7_form_elements', 'my_wpcf7_form_elements');
Add User to SQL Server Database
Add User Using Windows Authentication
-- Create user windows Authentication
CREATE LOGIN [YourDomainNameJohnJacobs] FROM WINDOWS
WITH DEFAULT_DATABASE = [YourDatabaseHere];
GO
-- Now add user to database
USE YourDatabaseHere;
CREATE USER JohnJacobs FOR LOGIN [YourDomainNameJohnJacobs];
-- If adding to a second database, do so below:
USE YourSecondDatabaseHere;
CREATE USER JohnJacobs FOR LOGIN [YourDomainNameJohnJacobs];
Add User Using SQL Authentication
-- Create user for SQL Authentication
CREATE LOGIN JohnJacobs WITH PASSWORD = 'JinGleHeimerSchmidt'
,DEFAULT_DATABASE = [YourDatabaseHere]
GO
-- Now add user to database
USE YourDatabaseHere;
CREATE USER JohnJacobs FOR LOGIN JohnJacobs;
GO
-- If adding to a second database, do so below:
USE YourSecondDatabaseHere;
CREATE USER JohnJacobs FOR LOGIN JohnJacobs;
Retina Display Media Query
For including high-res graphics, but only for screens that can make us of them. “Retina” being “2x”:
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) { /* Retina-specific stuff here */ }
Recent Comments