Skip to content

Instantly share code, notes, and snippets.

View shramee's full-sized avatar
🥳
Coding party

Shramee Srivastav shramee

🥳
Coding party
View GitHub Profile
@shramee
shramee / Gruntfile.js
Last active March 21, 2016 07:02
Gruntfile for using SASS with Grunt and Autoprefixer for a WordPress theme with SASS init `sass/style.scss` directory
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
/* Autoprefixing all css files in theme root */
autoprefixer: {
options : {
browsers : ['last 2 versions'],
},
multiple_files : {
@shramee
shramee / p5-particles.js
Last active March 1, 2017 06:33
Creates random particles with customizable properties
/**
* Created by shramee on 28/02/17.
*/
var particles = {},
particleProps = {},
particleFixOutOfViewport = function ( p, k ) {
var
flipSign = 1,
max = particleProps[ k + 'Max'];
if ( p[k] > max/2 ) { // if particle is in greater half
@shramee
shramee / pure-css-loader.scss
Last active June 23, 2017 06:21
Pure css animated spinning loader
/* SCSS */
@keyframes loader-anim {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
.loader {
width: 100px;
height: 100px;
@shramee
shramee / query-user-meta-table.php
Last active May 3, 2018 16:16
WordPress - Query user meta
<?php
/**
* Query user meta table
*
* @param string|array $name_patt Meta key pattern match
* @param string $query_suffix SQL query suffix
*
* @return array|null Results of query
*/
function shramee_query_user_meta_table( $name_patt, $query_suffix = '' ) {
@shramee
shramee / query-post-meta-table.php
Last active May 3, 2018 16:16
WordPress - Query post meta
<?php
/**
* Query post meta table
*
* @param string|array $name_patt Meta key pattern match
* @param string $query_suffix SQL query suffix
*
* @return array|null Results of query
*/
function shramee_query_post_meta_table( $name_patt, $query_suffix = '' ) {
@shramee
shramee / query-meta.php
Last active May 3, 2018 16:12
WordPress - Query post/user meta
<?php
/**
* Query user meta table
*
* @param string|array $name_patt Meta key pattern match
* @param string $query_suffix SQL query suffix
* @param bool $post_meta Whether to query post meta table
*
* @return array|null Results of query
*/
@shramee
shramee / query-user-meta.php
Last active May 3, 2018 16:14
Query user meta for a user
<?php
/**
* Query user meta
*
* @param string|array $name_patt Meta key pattern match
* @param int $uid User ID
* @param string $query_suffix SQL query suffix
*
* @return array|null Results of query
*/
@shramee
shramee / upwork-sum-pending.js
Last active July 23, 2018 15:45
Just paste this in console on page earnings history after logging in. https://www.upwork.com/earnings-history/
function getPending() {
var amount = 0;
$( 'tr.oPending' ).each( function() {
var
$t = $(this),
amt = $t.children( ':eq(4)' ).html().split( '<br>' )[0];
amt = amt.trim().replace( '$', '' )
if ( 0 == amt.indexOf( '(' ) ) {
amt = amt.replace( '(', '' ).replace( ')', '' ) * -1
}
<?php
/**
* Saves the file from file input and return attachment ID
* @param string $input_name Name of file input
* @param bool $return_id Whether
* @return int|string|WP_Error ID of the attachment or a WP_Error object on failure.
*/
function shramee_upload_media( $input_name, $return_id = false ) {
if ( ! function_exists( 'media_handle_upload' ) ) {
require_once ABSPATH . 'wp-admin/includes/image.php';
@shramee
shramee / backup.php
Created May 29, 2018 04:36 — forked from menzerath/backup.php
PHP: Recursively Backup Files & Folders to ZIP-File
<?php
/*
* PHP: Recursively Backup Files & Folders to ZIP-File
* MIT-License - 2012-2018 Marvin Menzerath
*/
// Make sure the script can handle large folders/files
ini_set('max_execution_time', 600);
ini_set('memory_limit', '1024M');