Skip to content

Instantly share code, notes, and snippets.

@rahulyhg
rahulyhg / laravellocal.md
Created March 23, 2019 12:59 — forked from hootlex/laravellocal.md
Run laravel project locally

##Windows users:

cmder will be refered as console

##Mac Os, Ubuntu and windows users continue here:

  • Create a database locally named homestead utf8_general_ci
public class LocationActivity extends AppCompatActivity
implements LocationContract.View {
@BindView(R.id.latitudeTextView)
TextView latitudeTextView;
@BindView(R.id.longitudeTextView)
TextView longitudeTextView;
@BindView(R.id.softDenyTextView)
TextView softDeniedWarningTextView;
@BindView(R.id.hardDenyTextView)
//Main activity for adding Location based mutes
package com.zeeshanak.mutemehere;
import java.util.ArrayList;
import java.util.List;
import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.api.GoogleApiClient;
import com.google.android.gms.common.api.GoogleApiClient.ConnectionCallbacks;
<?php
// Demo for session fixation
//
// Attacker creates a session by visiting the page: http://famfamfam.com/sessionfixation.php
// Attacker gets their session ID out of the cookie (or in this case from the page)
// Attacker creates a URL such as http://famfamfam.com/sessionfixation.php?PHPSESSID=attackerssessionid and sends it to victim
// Victim clicks the URL (now both the attacker and victim are using the same session)
// Victim logs in
// Now the attacker is logged in to the victim's account too (same session!)
@rahulyhg
rahulyhg / example.php
Created January 3, 2019 11:21 — forked from juzna/example.php
SessionId and randomness in PHP
<?php
/**
* Starts a PHP session and dump a random number
*/
session_start();
// do some stuff...
$password = mt_rand();
$otherRandomToken = rand();
@rahulyhg
rahulyhg / MySQLSession.php
Created January 3, 2019 11:19 — forked from rjha/MySQLSession.php
PHP MYSQL based session handler with locking using select for update
<?php
namespace com\indigloo\core {
use \com\indigloo\Configuration as Config;
use \com\indigloo\mysql\PDOWrapper;
use \com\indigloo\Logger as Logger;
/*
* custom session handler to store PHP session data into mysql DB
@rahulyhg
rahulyhg / functions.php
Created April 29, 2018 14:29
Display variations dropdowns on shop page for variable products
// Display variations dropdowns on shop page for variable products
add_action( 'woocommerce_after_shop_loop_item', 'woo_display_variation_dropdown_on_shop_page' );
function woo_display_variation_dropdown_on_shop_page() {
global $product;
if( $product->is_type( 'variable' )) {
$attribute_keys = array_keys( $product->get_variation_attributes() );
?>
@rahulyhg
rahulyhg / functions.php
Created April 27, 2018 17:18
Add content and notices to the WooCommerce checkout - sample code
/**
* Each of these samples can be used - note that you should pick one rather than add them all.
*
* How to use WC notices: https://github.com/woothemes/woocommerce/blob/master/includes/wc-notice-functions.php#L96
* Tutorial: http://www.skyverge.com/blog/edit-woocommerce-templates/
**/
/**
* Add a content block after all notices, such as the login and coupon notices.
*
@rahulyhg
rahulyhg / functions.php
Last active April 27, 2018 16:35
Display variations dropdown as table in woocommerce
//Display variations dropdown as table
function woocommerce_variable_add_to_cart() {
global $product, $post;
$variations = $product->get_available_variations();
foreach ($variations as $key => $value) {
?>
<form action="<?php echo esc_url( $product->add_to_cart_url() ); ?>"method="post" enctype='multipart/form-data'>
<input type="hidden" name="variation_id" value="<?php echo $value['variation_id']?>" />
<input type="hidden" name="product_id" value="<?php echo esc_attr( $post->ID ); ?>" />
<?php
@rahulyhg
rahulyhg / functions.php
Created April 27, 2018 16:33
Display WooCommerce product variations dropdown select on the shop page
// Display variations dropdowns on shop page for variable products
add_filter( 'woocommerce_loop_add_to_cart_link', 'woo_display_variation_dropdown_on_shop_page' );
function woo_display_variation_dropdown_on_shop_page() {
global $product;
if( $product->is_type( 'variable' )) {
$attribute_keys = array_keys( $product->get_variation_attributes() );
?>