Skip to content

Instantly share code, notes, and snippets.

@gorork
gorork / gist:b18c07205cf862291a64
Last active August 29, 2015 14:10
P2: JavaScript Challenge #1
var getRelationship = function(x, y) {
// If both arguments are numbers
if ( !isNaN(x) && !isNaN(y) ) {
if ( x == y ) { // if they are equal, return '='
return '=';
} else { // if not, return comparison operator
return x < y ? '<' : '>';

SMACSS + Sass + BEM

SMACSS

Scalable and
Modular
Architecture for
C
S
S

@munirkamal
munirkamal / Wordpress - Track and Display post views.php
Last active April 12, 2018 23:45
Wordpress snippet to track and display post or page views in your wordpress website without using any plugin.
/*******************************************************/
/ Shared by www.codewordpress.com /
/ Add following code to Function.php file in your theme /
/*******************************************************/
<?php
function getPostViews($postID){
$count_key = 'post_views_count';
$count = get_post_meta($postID, $count_key, true);
if($count==''){
@JeffCost
JeffCost / Git update-index --assume-unchanged.md
Created October 6, 2012 05:47 — forked from grafikchaos/Git update-index --assume-unchanged
Ignore uncommitted changes in tracked files with Git

IGNORE LOCAL CHANGES

Ignore local changes to repository files or directories git update-index --assume-unchanged path/to/file/or/directory

ALIAS

Or you can alias it in your ~/.gitconfig [alias] au = update-index --assume-unchanged

UN-IGNORE LOCAL CHANGES

@alpual
alpual / wp-enqueue-resources.php
Last active October 5, 2020 23:29
Wordpress Enqueue Scripts and Styles with timestamp
<?php
function my_load_scripts($hook) {
// create version codes
$my_js_ver = date("ymd-Gis", filemtime( get_stylesheet_directory() .'/js/myscript.js' ));
$my_css_ver = date("ymd-Gis", filemtime( get_stylesheet_directory() . '/style.css' ));
wp_enqueue_script( 'my-script-name', get_stylesheet_directory() . '/js/myscript.js', array(), $my_js_ver );
@ihorvorotnov
ihorvorotnov / get-social-shares
Last active October 20, 2020 12:15
Get number of shares from social platforms
Facebook*:
https://api.facebook.com/method/links.getStats?urls=%%URL%%&format=json
+ works, returns shares, likes, comments and total
Twitter:
http://urls.api.twitter.com/1/urls/count.json?url=%%URL%%&callback=twttr.receiveCount
+ v1 API but still works
Reddit:
http://buttons.reddit.com/button_info.json?url=%%URL%%
@revolunet
revolunet / angularjs.md
Last active October 22, 2021 00:36
BeerJS + AngularJS Paris le 25/2

AngularJS best ressources

Following the AngularJS PARIS meetup (25/2 à 19h à Paris with @sampaccoud @dzen @_kemar @tchack13 @vinz et @revolunet)

Here's our best AngularJS ressources : twitter, github, articles & blogs. Please comment and add your good stuff !

@mjangda
mjangda / ngrok-and-jetpack.md
Last active February 7, 2023 07:57
How to connect ngrok to your local WordPress environment (props @DanReyLop)

How to develop with Jetpack locally with ngrok

To connect Jetpack in your local installation, you'll need a way for WP.com servers to reach your server. That can be done in a number of different ways:

  • You can open your router's ports and use your public IP
  • You can use some kind of Dynamic DNS provider.

But these options fall short of ngrok, which is a "localhost tunnel". It basically allows the Internet to hit a local port on your machine without worrying about ports or IPs.

As long as ngrok is running, Jetpack / WP.com will be able to communicate with your local site. This will allow remote modules like Site Search and Manage to work.

@ssuess
ssuess / wordpress-import-update.php
Last active August 15, 2023 21:25 — forked from balbuf/wordpress-import-update.php
Force the WordPress importer to update existing posts instead of skipping them
<?php
/**
* When using the WordPress Importer, update existing
* posts instead of skipping them. Updates content according
* to the import file even if the existing post was updated
* more recently.
*
* To use, drop this file into your /mu-plugins/ folder or
* copy this code into your functions.php file.