Skip to content

Instantly share code, notes, and snippets.

View bitclaw's full-sized avatar

Bitclaw bitclaw

View GitHub Profile
@bitclaw
bitclaw / helpers.php
Created February 5, 2018 10:09 — forked from fer-ri/helpers.php
Delete Laravel Cache By Pattern
<?php
foreach (Cache::getMemory() as $cacheKey => $cacheValue)
{
if (strpos($cacheKey, 'mypackage') !== false)
{
Cache::forget($cacheKey);
}
}
@bitclaw
bitclaw / gist:c23a975efc351b7c178837f97d37bcbe
Created January 2, 2018 15:12 — forked from jrmadsen67/gist:bd0f9ad0ef1ed6bb594e
Laravel Quick Tip: Handling CsrfToken Expiration gracefully
Quick tip for handling CSRF Token Expiration - common issue is when you use csrf protection is that if
a form sits there for a while (like a login form, but any the same) the csrf token in the form will
expire & throw a strange error.
Handling it is simple, and is a good lesson for dealing with other types of errors in a custom manner.
In Middleware you will see a file VerifyCsrfToken.php and be tempted to handle things there. DON'T!
Instead, look at your app/Exceptions/Handler.php, at the render($request, Exception $e) function.
All of your exceptions go through here, unless you have excluded them in the $dontReport array at the
@bitclaw
bitclaw / multiple_ssh_setting.md
Created November 11, 2017 09:24 — forked from jexchan/multiple_ssh_setting.md
Multiple SSH keys for different github accounts

Multiple SSH Keys settings for different github account

create different public key

create different ssh key according the article Mac Set-Up Git

$ ssh-keygen -t rsa -C "your_email@youremail.com"
@bitclaw
bitclaw / deploy.php
Created October 15, 2017 02:55 — forked from nickdenardis/deploy.php
Zero downtime local build Laravel 5 deploys with Deployer
<?php
namespace Deployer;
require 'recipe/laravel.php';
require 'vendor/deployer/recipes/local.php';
require 'vendor/deployer/recipes/rsync.php';
require 'vendor/deployer/recipes/npm.php';
// Configuration
set('ssh_type', 'native');
@bitclaw
bitclaw / GIT-CHEATSHEET.md
Last active March 26, 2019 08:44
GIT CHEATSHEET

Using Git

The "Oh crap I didn't mean to commit yet" Trick

# undo last commit and bring changes back into staging (i.e. reset to the commit one before HEAD)
$ git reset --soft HEAD^
@bitclaw
bitclaw / useful_git_commands.txt
Last active June 8, 2017 14:51
useful git commands
git rebase -i HEAD~n (Where n is the number of commits, useful for squashing several meaningless commits into one)
git push -f
Useful links:
https://github.com/edx/edx-platform/wiki/How-to-Rebase-a-Pull-Request
@bitclaw
bitclaw / webstorm64.vmoptions
Last active March 5, 2023 11:14
Jetbrains Custom VM Options Optimized Configuration: Performance tuning parameters for IntelliJ IDEA. Add these params in idea64.exe.vmoptions or idea.exe.vmoptions file in IntelliJ IDEA. If you are using JDK 8.x, please knock off PermSize and MaxPermSize parameters from the tuning configuration.
# custom WebStorm VM options, this configuration also works well for other IDEs like phpstorm, pycharm..etc.
-Xms1024m
-Xmx2048m
-XX:ReservedCodeCacheSize=240m
-XX:+UseConcMarkSweepGC
-XX:SoftRefLRUPolicyMSPerMB=50
-ea
-Dsun.io.useCanonCaches=false
-Djava.net.preferIPv4Stack=true

Keybase proof

I hereby claim:

  • I am bitclaw on github.
  • I am bitclaw (https://keybase.io/bitclaw) on keybase.
  • I have a public key whose fingerprint is C1B5 1958 F8F8 DB11 B166 8802 9AFA 07FA 6E94 5570

To claim this, I am signing this object:

@bitclaw
bitclaw / 0. intro.md
Created January 15, 2017 16:50 — forked from jquense/0. intro.md
Alternative ways to define react Components

The 0.13.0 improvements to React Components are often framed as "es6 classes" but being able to use the new class syntax isn't really the big change. The main thing of note in 0.13 is that React Components are no longer special objects that need to be created using a specific method (createClass()). One of the benefits of this change is that you can use the es6 class syntax, but also tons of other patterns work as well!

Below are a few examples creating React components that all work as expected using a bunch of JS object creation patterns (https://github.com/getify/You-Dont-Know-JS/blob/master/this%20&amp;%20object%20prototypes/ch4.md#mixins). All of the examples are of stateful components, and so need to delegate to React.Component for setState(), but if you have stateless components each patterns tends to get even simpler. The one major caveat with react components is that you need to assign props and context to the component instance otherwise the component will be static. The reason is

@bitclaw
bitclaw / mongo-queries.js
Last active November 21, 2016 14:10
MongoDB Queries
// Get record by subobject
db.protocol.find({"study.official_title": "TEST"})
db.protocol.find({"study.official_title": "TEST"},{"events": 1})