Skip to content

Instantly share code, notes, and snippets.

@nomaanp
nomaanp / useWebSockets.tsx
Created November 15, 2020 12:21 — forked from jonasgroendahl/useWebSockets.tsx
useWebSockets()
import {useEffect, useRef, useState} from 'react';
import io from 'socket.io-client';
type Props = {
userId: number;
enabled: boolean;
onConnected?: () => void;
};
type Message = {
@nomaanp
nomaanp / axios-catch-error.js
Created December 9, 2019 15:25 — forked from fgilio/axios-catch-error.js
Catch request errors with Axios
/*
* Handling Errors using async/await
* Has to be used inside an async function
*/
try {
const response = await axios.get('https://your.site/api/v1/bla/ble/bli');
// Success 🎉
console.log(response);
} catch (error) {
// Error 😨
@nomaanp
nomaanp / multiple_ssh_setting.md
Created October 11, 2016 13:08 — 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"
$inputFilter->add($factory->createInput(array(
'name' => 'username',
'required' => true,
'filters' => array(
array('name' => 'StripTags'),
array('name' => 'StringTrim'),
),
'validators' => array(
array(
'name' => 'StringLength',
@nomaanp
nomaanp / request.php
Created August 13, 2013 10:37
var dump for $this->getRequest();
object(Zend\Http\PhpEnvironment\Request)#127 (14) { ["baseUrl":protected]=> string(0) "" ["basePath":protected]=> NULL ["requestUri":protected]=> string(20) "/member/authenticate" ["serverParams":protected]=> object(Zend\Stdlib\Parameters)#129 (1) { ["storage":"ArrayObject":private]=> array(39) { ["CONTENT_LENGTH"]=> string(2) "49" ["CONTENT_TYPE"]=> string(33) "application/x-www-form-urlencoded" ["DOCUMENT_ROOT"]=> string(26) "/home/marwaric/public_html" ["GATEWAY_INTERFACE"]=> string(7) "CGI/1.1" ["HTTP_ACCEPT"]=> string(63) "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8" ["HTTP_ACCEPT_ENCODING"]=> string(17) "gzip,deflate,sdch" ["HTTP_ACCEPT_LANGUAGE"]=> string(14) "en-US,en;q=0.8" ["HTTP_CACHE_CONTROL"]=> string(9) "max-age=0" ["HTTP_CONNECTION"]=> string(10) "keep-alive" ["HTTP_HOST"]=> string(22) "marwarishaadicentre.in" ["HTTP_ORIGIN"]=> string(29) "http://marwarishaadicentre.in" ["HTTP_REFERER"]=> string(30) "http://marwarishaadicentre.in/" ["HTTP_USER_AGENT"]=> string(101) "Mozilla/
@nomaanp
nomaanp / module.config
Created August 8, 2013 07:12
module.config for Profile module
<?php
return array(
'controllers' => array(
'invokables' => array(
'Profile' => 'Profile\Controller\ProfileController',
),
),
'router' => array(
'routes' => array(
@nomaanp
nomaanp / authcontroller
Created August 8, 2013 06:56
redirection problem after authenticateAction
public function authenticateAction()
{
$user_session = new Container('user');
$form = $this->getForm();
$redirect = 'member/login';
$request = $this->getRequest();
if($request->isPost())
{
@nomaanp
nomaanp / Module_App1
Created July 25, 2013 05:03
Logout problem in SanAuth
Module.php for App1
<?php
namespace App1;
class Module
{
public function getAutoloaderConfig(){} /*Common Code*/
public function getConfig(){} /* Common Code */