Skip to content

Instantly share code, notes, and snippets.

View steve-todorov's full-sized avatar

Steve Todorov steve-todorov

  • Carlspring Ltd.
  • Bulgaria
View GitHub Profile
// /etc/polkit-1/rules.d/10-rules.rules
// PolKit rules to allow mounting, rebooting and network management without a password.
// User needs to be in storage, power and network groups.
polkit.addRule(function(action, subject) {
if (action.id.match("org.freedesktop.udisks2.") && subject.isInGroup("storage")) {
return polkit.Result.YES;
}
});
<?php
namespace Acme\HelloBundle\Menu;
use Knp\Menu\FactoryInterface;
use Symfony\Component\DependencyInjection\ContainerAware;
class MenuBuilder extends ContainerAware
{
public function mainMenu(FactoryInterface $factory, array $options)
@steve-todorov
steve-todorov / symfony-build-example.xml
Last active August 29, 2015 14:18 — forked from hectorsanjuan/build.xml
symfony-build-example.xml
<?xml version="1.0" encoding="UTF-8"?>
<project name="${projectName}" basedir="." default="build:main">
<!-- Properties -->
<property name="dir.app" value="${project.basedir}/app" />
<property name="dir.src" value="${project.basedir}/src" />
<property name="dir.build" value="${project.basedir}/app/build" />
<property name="dir.docs" value="${dir.build}/docs" />
<property name="dir.docs.phpdoc" value="${dir.docs}/phpdoc" />
<property name="dir.docs.docblox" value="${dir.docs}/docblox" />
<property name="dir.reports" value="${dir.build}/logs" />
@steve-todorov
steve-todorov / csv-to-array.php
Last active August 29, 2015 14:19
Get csv data as an array
<?php
set_time_limit(0);
ini_set('memory_limit',-1);
function parse_csv_assoc($str,&$f) {
if (empty($f)) { $f = str_getcsv($str); }
return @array_combine($f, str_getcsv($str));
}
$filename="export.csv";
header("Content-type: application/octet-stream");
header("Content-Disposition: attachment; filename=$filename");
header("Pragma: no-cache");
header("Expires: 0");
$csv = fopen('php://output', 'w');
foreach($rows as $ind=>$row){
if($ind==0)
fputcsv($csv,array_keys($row));
@steve-todorov
steve-todorov / ng-if-false.htm
Created September 25, 2015 23:54 — forked from bennadel/ng-if-false.htm
Creating A Pre-Bootstrap Loading Screen In AngularJS
<!-- BEGIN: Pre-Bootstrap Loading Screen. -->
<div ng-if="false">
<p>
This will show until the application is bootstrapped.
Then, the ngIf directive will immediately rip it out of
the page.
</p>
</div>
<?php
class DefaultController extends Controller
{
/**
* Dashboard page.
* @Permissions(perm="dashboard_view")
* @Route("/", name="ITEDashboardBundle_index")
* @Template()
* @return array
@steve-todorov
steve-todorov / 0_reuse_code.js
Last active October 18, 2015 20:47
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@steve-todorov
steve-todorov / Fix SUSE suspend
Last active October 25, 2017 14:58
Fix SUSE suspend
1. Check if /etc/default/grub has
GRUB_CMDLINE_LINUX_DEFAULT=" resume=/dev/sda2 splash=silent quiet showopts"
and "resume" points to the correct SWAP partition.
2. Check if using any nvidia drivers. If so - uninstall them and make sure to remove any files that blacklist "nouveau":
cd /etc/modprobe.d/
grep -i -R "nouveau" .
@steve-todorov
steve-todorov / symfony-cache-clear.php
Created November 18, 2015 22:48
A way to easily clear symfony cache without wiping out absolutely everything from the cache/ENV directory.
<?php
class MyController extends Controller {
public function myAction() {
$finder = new Finder();
/**
* @var SplFileInfo $file
*/
foreach($finder->name('*ProjectContainer*')->depth(0)->in($this->getParameter('kernel.cache_dir')) as $file){