Skip to content

Instantly share code, notes, and snippets.

View arghav's full-sized avatar

arghav arghav

View GitHub Profile
@arghav
arghav / Axios.js
Last active August 14, 2021 10:49
React context API with Axios
import * as React from 'react';
import axios from 'axios';
import isEqual from 'lodash.isequal';
class Axios extends React.Component {
constructor(props) {
super(props);
// NOTE: Do not use this.context as React uses it internally
this.axiosContext = React.createContext(this.value);
@arghav
arghav / epicTypekit.js
Created February 5, 2013 06:31
Load typekit on EpicEditor
editor.on('load', function () {
// Step 1: Grab the editor element
var editorDoc = editor.getElement('editor');
// Step 2: Create the script tag
var script = editorDoc.createElement('script');
script.type = 'text/javascript';
script.innerHTML = "(function() {var config = {kitId: '<yourKitID>'}; var d = false; var tk = document.createElement('script'); tk.src = '//use.typekit.net/' + config.kitId + '.js'; tk.type = 'text/javascript'; tk.async = 'true'; tk.onload = tk.onreadystatechange = function() {var rs = this.readyState; if (d || rs && rs != 'complete' && rs != 'loaded') return; d = true; try { Typekit.load(config); } catch (e) {} }; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(tk, s); })();";
// Step 3: Add it to the editor's <head>
SetEnvIfNoCase Host domain2\.co\.uk SYMFONY__DOMAIN__NAME=domain2
<?php
// app/AppKernel.php
public function registerContainerConfiguration(LoaderInterface $loader)
{
$envParameters = $this->getEnvParameters();
if (@$envParameters['domain.name'] == 'domain2') {
$loader->load(__DIR__.'/config/domain2/config_'.$this->getEnvironment().'.yml');
} else {
{
"name": "friendsofsymfony/twitter-bundle",
"type": "symfony-bundle",
"description": "Symfony FOSTwitterBundle",
"keywords": ["Twitter authentication"],
"homepage": "http://friendsofsymfony.github.com",
"license": "MIT",
"authors": [
{
"name": "FriendsOfSymfony Community",
@arghav
arghav / config.yml
Created May 24, 2011 06:52
PdoSessionStorage with DBAL connection
parameters:
pdo.options: []
pdo.db_options:
db_table: session
services:
session.storage.pdo:
class: Symfony\Component\HttpFoundation\SessionStorage\PdoSessionStorage
arguments:
- @doctrine.dbal.default.wrapped_connection
@arghav
arghav / session_table.sql
Created May 11, 2011 08:01
SQL dump of my session table
CREATE TABLE `session` (
`sess_id` varchar(255) NOT NULL,
`sess_data` text NOT NULL,
`sess_time` int(11) NOT NULL,
PRIMARY KEY (`sess_id`),
UNIQUE KEY `sess_id_idx` (`sess_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
@arghav
arghav / config.yml
Created May 11, 2011 07:59
app/config/config.yml
framework:
#...
session:
default_locale: %locale%
lifetime: 3600
auto_start: true
storage_id: session.storage.pdo
#...
parameters:
<?php
namespace Flock\MainBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Flock\MainBundle\Form\EventForm;
use Flock\MainBundle\Entity\Event;
class DefaultController extends Controller
{
@arghav
arghav / ResolveDefinitionTemplatesPass.php
Created March 9, 2011 12:13
Suppress exception if abstract
if (!$this->container->hasDefinition($parent = $definition->getParent())) {
if ($definition->isAbstract()) {
return null;
}
throw new \RuntimeException(sprintf('The parent definition "%s" defined for definition "%s" does not exist.', $parent, $id));
}