Skip to content

Instantly share code, notes, and snippets.

View sworup's full-sized avatar
🦖
Normal

Sworup Shakya sworup

🦖
Normal
View GitHub Profile
@sworup
sworup / gist:d08f34579a1028b837cd045bec65a4a9
Created February 9, 2019 10:56
My Windows BoxStarter Script
# Configure Windows
Set-WindowsExplorerOptions -EnableShowHiddenFilesFoldersDrives -EnableShowProtectedOSFiles -EnableShowFileExtensions -EnableShowFullPathInTitleBar
Enable-RemoteDesktop
Update-ExecutionPolicy Unrestricted
cinst -y Microsoft-Hyper-V-All -source windowsFeatures
# Packages
cinst -y hyper
@sworup
sworup / 01-scrum.md
Last active June 29, 2017 09:57
Scrum Documentation

Referenced from The Scrum Guide by Ken Schwaber and Jeff Sutherland

Scrum Definition

  • The Scrum framework consists of Scrum Teams and their associated roles, events, artifacts, and rules.
  • The rules of Scrum bind together the events, roles, and artifacts, governing the relationships and interaction between them.
  • Scrum is founded on empirical process control theory, or empiricism.
  • Empiricism asserts that knowledge comes from experience and making decisions based on what is known.
  • Scrum employs an iterative, incremental approach to optimise predictability and control risk.
@sworup
sworup / checkout_rebase.git
Last active June 16, 2017 06:11
Git commands listing
git checkout develop && git pull --rebase
@sworup
sworup / utf8_decode_all.php
Created March 1, 2017 10:16
Decode all the values in an array to UTF-8
<?php
function utf8_decode_all($dat)
{
if (is_string($dat)) return utf8_decode($dat);
if (!is_array($dat)) return $dat;
$ret = array();
foreach($dat as $i=>$d) $ret[$i] = utf8_decode_all($d);
return $ret;
}
@sworup
sworup / w1250_to_utf8_converter.php
Created March 1, 2017 10:08
Foreign Charater to UTF8 converter
<?php
function w1250_to_utf8($text) {
// map based on:
// http://konfiguracja.c0.pl/iso02vscp1250en.html
// http://konfiguracja.c0.pl/webpl/index_en.html#examp
// http://www.htmlentities.com/html/entities/
$map = array(
chr(0x8A) => chr(0xA9),
chr(0x8C) => chr(0xA6),
@sworup
sworup / sql_log.php
Created December 27, 2016 07:38
Adding a DB Listener to log the sql query in log file
<?php
use Illuminate\Support\Facades\Log;
\DB::listen(function($sql, $bindings, $time) {
Log::info($sql);
Log::info($bindings);
Log::info($time);
});
// Your query goes after this
@sworup
sworup / npm-debug.log
Created December 9, 2016 10:05
Error while doing npm install in mac osx vagrant build with Laravel
npm WARN deprecated [email protected]: ReDoS vulnerability parsing Set-Cookie https://nodesecurity.io/advisories/130
npm WARN deprecated [email protected]: use uuid module instead
npm WARN deprecated [email protected]: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
npm WARN deprecated [email protected]: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
npm WARN deprecated [email protected]: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
npm WARN deprecated [email protected]: graceful-fs v3.0.0 and before will fail on node releases >= v7.0. Please update to graceful-fs@^4.0.0 as soon as possible. Use 'npm ls graceful-fs' to find it in the tree.
npm WARN prefer global [email protected] should be installed with -g
npm WARN prefer global [email protected] should be installed with -g
npm WARN prefer global [email protected] should be installed with -g
@sworup
sworup / AppServiceProvider.php
Created December 9, 2016 06:13
Load config files from a directory
<?php
namespace Sworup\Providers;
use Illuminate\Support\ServiceProvider;
use Symfony\Component\Finder\Finder;
class AppServiceProvider extends ServiceProvider
{
public function boot()
{
}
@sworup
sworup / laravel-add-after-in-request.php
Created July 31, 2016 07:00
Laravel- Add after hook in request file. Reference: https://goo.gl/8BhhCB
<?php
/**
* Get the validator instance for the request and
* add attach callbacks to be run after validation
* is completed.
*
* @return \Illuminate\Contracts\Validation\Validator
*/
protected function getValidatorInstance()
{
@sworup
sworup / laravel-validation-error.js
Last active July 9, 2021 13:04
Handling of Laravel validation message when pulled through Ajax request
error: function (request) {
// Validation error would return 422 header
if (request.status == 422) {
// Parser the json response expected
var $errors = $.parseJSON(request.responseText);
// Bootstrap alert scafolding for error
var errorsHtml = '<div class="alert alert-danger alert-dismissible"><button aria-hidden="true" data-dismiss="alert" class="close" type="button">×</button><h4><i class="icon fa fa-times"></i>Opps! Seems like you didn\'t fill the form properly...</h4><ul>';
// The root nodes are field names, with an array of error messages
$.each( $errors, function( key, value ) {
// We loop through the error to see if there are multiple error associated with the field