Skip to content

Instantly share code, notes, and snippets.

View shengjie's full-sized avatar
😉

Shengjie shengjie

😉
View GitHub Profile
@shengjie
shengjie / update_composer_lock.php
Created September 17, 2019 08:19
Update composer lock given package reference fastly
<?php
$lockFile = $argv[1];
$packageName = $argv[2];
$ref = $argv[3];
if ($argc !== 4) {
echo "Usage update_lock.php composer.lock mypackage 123abc\n";
exit;
}
<?php
namespace AppBundle\Command;
use JMS\Serializer\Metadata\PropertyMetadata;
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
@shengjie
shengjie / AsseticGulpGenerateCommand
Created December 23, 2016 10:29
generate gulp config from assetic
use Assetic\Asset\AssetCollectionInterface;
use Assetic\Asset\AssetInterface;
use Assetic\Factory\LazyAssetManager;
use Assetic\Filter\CompassFilter;
use Assetic\Filter\CssRewriteFilter;
use Assetic\Filter\PhpCssEmbedFilter;
use Assetic\Filter\UglifyCssFilter;
use Assetic\Filter\UglifyJs2Filter;
use Assetic\Util\VarUtils;
@shengjie
shengjie / StringCaseUtils.php
Last active September 11, 2015 12:58
Simple helper function to convert camelCase <=> snakeCase
<?php
class StringCaseUtils
{
public static function toSnakeCase($camelCase)
{
return strtolower(preg_replace('/([A-Z])/', '_$1', lcfirst($camelCase)));
}
public static function toCamelCase($snakeCase)
@shengjie
shengjie / bootstrap-nav-stacked-admin.css
Created August 27, 2015 09:11
Admin style bootstrap nav-stacked improvements, has css3 white box arrow with black theme
.nav.nav-stacked .nav-item {
border-bottom: 1px solid #666;
}
.nav.nav-stacked .nav-item a {
color: #fff;
border-radius: 0;
position: relative;
}
@shengjie
shengjie / directive-circle-stats.js
Created August 27, 2015 09:08
Angular directive draw an circle stats with number and unit inside
app.directive("circleStats", function () {
return {
restriction: 'E',
scope: {
ngModel: "="
},
link: function (scope, element, attrs) {
var canvas = document.createElement("canvas");
var g2d = canvas.getContext("2d");
var h = g2d.canvas.height = 200;
@shengjie
shengjie / MetaRedirectResponse.php
Last active August 29, 2015 14:27
A simple solution for captureable redirect response. browser can handle this response easily
<?php
use Symfony\Component\HttpFoundation\Response;
class MetaRedirectResponse extends Response
{
/**
* Constructor.
*
* @param mixed $content The response content, see setContent()
@shengjie
shengjie / ImplementationInjectPass.php
Last active August 29, 2015 14:25
Auto inject implementation of interface (must tagged with "implementation_inject").
<?php
/**
* @author: shengjie
* @date: 24/07/15 15:33
* @file: ImplementationInjectPass.php
*/
namespace AppBundle\DependencyInjection;
@shengjie
shengjie / RepositoryGeneratorCommand.php
Last active August 29, 2015 14:25
generate xml repository service definition for all entities
<?php
/**
* @author: shengjie
* @date: 16/07/15 16:10
* @file: GenerateCommand.php
* @Licence: MIT
*/
namespace AppBundle\Command;