Skip to content

Instantly share code, notes, and snippets.

View sunnyluthra's full-sized avatar

Sunny Luthra sunnyluthra

View GitHub Profile
@sunnyluthra
sunnyluthra / verify_android_push_notification_token.php
Created August 25, 2015 18:49
verify_android_push_notification_token.php
function verify_notification_token($token) {
$fields = array(
'dry_run' => true,
'to' => $token,
);
$headers = array(
'Authorization: key=' . GOOGLE_API_SERVER_KEY,
'Content-Type: application/json',
);
$ch = curl_init();
<?php
/*
Plugin Name: Bot For WP
Description: Messenger bot for WordPress
Plugin URI: http://snypd.com/
Author: Sunny Luthra
Author URI: http://#
Version: 1.0
License: GPL2
*/
@sunnyluthra
sunnyluthra / deletePendingPosts.js
Last active March 1, 2016 04:36
It will delete all the pending posts
var deleteSpam = {
count: 0,
list: null,
timeout: 500,
//Selector of cross(x) link
crossSelector: '.userContentWrapper [aria-label="Delete"]',
//Selector for buttons wrapper in overlay box which appears when we click on cross icon
overlayPresenseSelector: '.uiOverlayFooter',
//Delete button selector on overlay box
confirmDeleteButtonSelector: 'button.layerConfirm',
@sunnyluthra
sunnyluthra / array angl
Created December 17, 2013 04:33
Angl sample data
Array
(
[avatar] => https://s3.amazonaws.com/photos.angel.co/users/237099-medium_jpg?1382091520
[name] => Pathan Salman Khan
[bio] => Graduate from CSE, IITB. Active programmer in Codeforces, TopCoder and Hackerrank and other platforms.
[header_links] => Array
(
[linked_in-link] => http://www.linkedin.com/profile/view?id=84285625&trk=nav_responsive_tab_profile
[twitter-link] => https://twitter.com/pathansalman
[facebook-link] => http://www.facebook.com/pskhan1
@sunnyluthra
sunnyluthra / CharacterLimiter.php
Created November 21, 2013 05:37
Limits the string based on the character count. Preserves complete words so the character count may not be exactly as specified.
<?php
/**
* Character Limiter
*
* Limits the string based on the character count. Preserves complete words
* so the character count may not be exactly as specified.
*
* @access public
* @param string
* @param integer
@sunnyluthra
sunnyluthra / find_user_with_skills.php
Created October 27, 2015 08:55
Find wordpress user by meta values
<?php
$args = array(
'meta_query' => array(
'relation' => 'OR',
array(
'key' => 'skill',
'value' => 'php',
'compare' => '='
),
@sunnyluthra
sunnyluthra / gist:3479002
Created August 26, 2012 13:05 — forked from lucasfais/gist:1207002
Sublime Text 2 - Useful Shortcuts

Sublime Text 2 – Useful Shortcuts (Mac OS X)

General

⌘T go to file
⌘⌃P go to project
⌘R go to methods
⌃G go to line
⌘KB toggle side bar
⌘⇧P command prompt
@sunnyluthra
sunnyluthra / php_ssl_check.php
Created August 21, 2012 21:25
If a request arrived over ssl
<?php
if ('on' == $_SERVER['HTTPS']) {
//Yes, HTTPS request.
else{
//Http request
}
?>
@sunnyluthra
sunnyluthra / get_user_id_by_meta.php
Last active October 8, 2015 06:39
WordPress get user by metakey and value
<?php
function get_user_id_by_meta($key, $value) {
if (!$key && !$value) {
return false;
}
$args = array(
'meta_key' => $key,
'meta_value' => $value,
'fields' => 'ids',
'count_total' => false,
@sunnyluthra
sunnyluthra / padding-margin.sass
Created September 9, 2015 07:53
Padding Class Generator
@mixin class-generator($classNamespace, $fromValue, $toValue, $multiple, $property, $unit) {
@for $i from $fromValue to $toValue {
.#{$classNamespace}#{$i*$multiple} {
#{$property}: #{$i*$multiple}#{$unit};
}
}
}
@include class-generator(pt, 0, 25, 5, padding-top, px);