Skip to content

Instantly share code, notes, and snippets.

View harddy's full-sized avatar

Hardik Thakkar harddy

  • Anand, Gujarat, India
View GitHub Profile
@harddy
harddy / array-insert-after.php
Created July 15, 2019 10:44
PHP - Insert a new element after a specific key/value pair
<?php
/**
* Insert a value or key/value pair after a specific key in an array. If key doesn't exist, value is appended
* to the end of the array.
*
* @param array $array
* @param string $key
* @param array $new
*
* @return array
@harddy
harddy / google-recaptcha-bypass.txt
Created December 14, 2018 13:34
Bypass Google Recaptcha for development purposes
With the following test keys, you will always get No CAPTCHA and all verification requests will pass.
Site key: 6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI
Secret key: 6LeIxAcTAAAAAGG-vFI1TnRWxMZNFuojJ4WifJWe
@harddy
harddy / ngrok-virtual-host.txt
Created October 17, 2018 12:34
NGRok for Virtual Hosts
ngrok http -host-header=rewrite site1.dev:80
@harddy
harddy / jshipster_and_and.js
Created July 29, 2018 15:30 — forked from berzniz/jshipster_and_and.js
Some small javascript hacks for hipsters
// Boring
if (isThisAwesome) {
alert('yes'); // it's not
}
// Awesome
isThisAwesome && alert('yes');
// Also cool for guarding your code
var aCoolFunction = undefined;
<?php
$count = count($main_array['fname']);
for($i = 0 ; $i < $count ; $i++ ) {
echo "First Name : " . $main_array['fname'][$i] ."<br>";
echo 'Last Name : ' . $main_array['lname'][$i] ."<br>";
}
<?php
Array
(
[fname] => Array
(
[0] => Student 1
[1] => Student 2
)
@harddy
harddy / functions.php
Created February 17, 2018 15:02
functions.php
<?php
if (!defined('ABSPATH'))
exit;
// BEGIN ENQUEUE PARENT ACTION
// AUTO GENERATED - Do not modify or remove comment markers above or below:
if (!function_exists('chld_thm_cfg_parent_css')):
<?php
/*
Template Name: dashboadrd
*/
?>
<form method="POST" action="">
<input type="submit" name="Sinkdata" value="Add data" />
</form>
<?php
if (isset($_POST['Sinkdata'])) {
@harddy
harddy / slug.php
Created June 27, 2017 12:03
Create Clean Slugs
function slugify($text)
{
// replace non letter or digits by -
$text = preg_replace('~[^\pL\d]+~u', '-', $text);
// transliterate
$text = iconv('utf-8', 'us-ascii//TRANSLIT', $text);
// remove unwanted characters
$text = preg_replace('~[^-\w]+~', '', $text);
@harddy
harddy / theme_option_repeater.php
Created October 23, 2016 05:33
Theme Option Repeater
/*
* Define a custom option type
* this type will repeat some text inputs
*/
function repeat_text_option_type($option_name, $option, $values) {
$counter = 0;
$output = '<div class="of-repeat-loop">';