Skip to content

Instantly share code, notes, and snippets.

View blacksmoke26's full-sized avatar
🏠
"You have a heart and I love you for being ashamed to show it". ― Nietzsche

Junaid Atari blacksmoke26

🏠
"You have a heart and I love you for being ashamed to show it". ― Nietzsche
View GitHub Profile
/** @jsx React.DOM */
var MyComponent = React.createClass({
render: function() {
// Defaults in case the props are undefined. We'll have a solution for this
// soon that is less awkward.
var perMinute = this.props.perMinute || '-';
var perDay = this.props.perDay || '-';
return (
<div>
<h3>Clickouts</h3>
@stubailo
stubailo / graphql-subscriptions-client.js
Created October 2, 2016 16:51
Use subscriptions-transport-ws to run a GraphQL subscription from a JavaScript client.
// To run this code yourself:
// 1. Download and run the demo server: https://github.com/apollostack/frontpage-server
// 2. Use create-react-app to create a build system
// 3. npm install subscriptions-transport-ws
// 4. Replace all of the code in src/ with just this file
import { Client } from 'subscriptions-transport-ws';
const client = new Client('ws://localhost:8090');
@pascalbaljet
pascalbaljet / imagick-3.4.0-PHP7-forge.sh
Last active November 26, 2020 09:10
Install Imagick 3.4.0 on PHP 7.0 server (Laravel Forge)
#!/bin/bash
if [ "$EUID" -ne 0 ]
then echo "Please run as root"
exit
fi
apt-get install pkg-config libmagickwand-dev -y
cd /tmp
wget https://pecl.php.net/get/imagick-3.4.0.tgz
tar xvzf imagick-3.4.0.tgz
@khanhtran3005
khanhtran3005 / php - nodejs
Last active September 14, 2021 04:14
Share session between PHP and NodeJS
http://stackoverflow.com/questions/24296212/php-nodejs-and-sessions#24303059
You can use memcached as your session storage handler in PHP. Memcached is a simple key value store that can be accessed via TCP; there is a memcached module available for Node.js.
PHP stores the session in memcached by using the session id as the key. The session data (value) stored in memcached is a serialized PHP object, with a slight twist. You can read more about this unusual serialization at the SO question "Parse PHP Session in Javascript". Luckily though, there is already an NPM module out there: php-unserialize.
Now for the How-To.
Assumptions
/** @jsx React.DOM */
var MyComponent = React.createClass({
getInitialState: function() {
// set up the initial state. used for "logical" initialization code
return {perMinute: '-', perDay: '-'};
},
componentDidMount: function() {
// fired only once, when the component is added to the DOM
// used for initialization code that has "side effects" i.e. i/o, jquery plugins, etc
var socket = io.connect(this.props.url);
@varunon9
varunon9 / graphql-query-client-side.js
Created May 26, 2018 17:41
Querying to graphql server from browser using JQuery Ajax
var globals = {}; // application wide global variable
globals.constants = {
}
globals.showToastMessage = function(heading, message, icon) {
$.toast({
heading: heading,
text: message,
showHideTransition: 'slide',
@gradosevic
gradosevic / gulpfile_react.js
Last active November 24, 2022 06:27
Working gulpfile.js with gulp-babel ES6 and React
var gulp = require('gulp');
var babel = require("gulp-babel");
var sourcemaps = require('gulp-sourcemaps');
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
gulp.task('default', () => {
return gulp.src('js/main.js')
.pipe(sourcemaps.init())
.pipe(babel({
@faisalman
faisalman / analytics-regexp.js
Created April 18, 2011 08:06
Regular Expression snippets to validate Google Analytics tracking code (in PHP, JavaScript)
/**
* Regular Expression snippets to validate Google Analytics tracking code
* see http://code.google.com/apis/analytics/docs/concepts/gaConceptsAccounts.html#webProperty
*
* @author Faisalman <movedpixel@gmail.com>
* @license http://www.opensource.org/licenses/mit-license.php
* @link http://gist.github.com/faisalman
* @param str string to be validated
* @return Boolean
*/
@agrueneberg
agrueneberg / client.html
Last active March 19, 2023 06:48
HMAC-SHA256 example for verifying both the data integrity and the authentication of a request in Node.js and web browsers.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>HMAC-SHA256 Example</title>
</head>
<body>
<script src="http://crypto.stanford.edu/sjcl/sjcl.js"></script>
<script>
var sharedSecret, query, signature, hmac, xhr;
@izazueta
izazueta / visor-archivos-online.md
Last active July 20, 2023 09:32
Google Docs Viewer & Office Web Apps Viewer

Google Docs Viewer

Only files under 25 MB can be previewed with the Google Drive viewer.

Google Drive viewer helps you preview over 16 different file types, listed below:

  • Image files (.JPEG, .PNG, .GIF, .TIFF, .BMP)
  • Video files (WebM, .MPEG4, .3GPP, .MOV, .AVI, .MPEGPS, .WMV, .FLV)
  • Text files (.TXT)
  • Markup/Code (.CSS, .HTML, .PHP, .C, .CPP, .H, .HPP, .JS)
  • Microsoft Word (.DOC and .DOCX)