Skip to content

Instantly share code, notes, and snippets.

@alopes
alopes / reddit.js
Created Oct 1, 2018
delete reddit comments
View reddit.js
var $domNodeToIterateOver = $('.del-button .option .yes'),
currentTime = 0,
timeInterval = 500;
$domNodeToIterateOver.each(function() {
var _this = $(this);
currentTime = currentTime + timeInterval;
setTimeout(function() {
@alopes
alopes / Config.js
Last active Jul 16, 2018
Storybook with react-starter-kit
View Config.js
// .storybook/Config.js
import React from 'react';
import PropTypes from 'prop-types';
import { configure, addDecorator } from '@storybook/react';
import ContextProvider from './ContextProvider';
function loadStories() {
require('../stories');
}
@alopes
alopes / async-component.spec.js
Created Sep 28, 2016 — forked from mrparkers/async-component.spec.js
Unit testing an async React component using Mocha, Chai, and Enzyme
View async-component.spec.js
import AsyncComponent from './path/to/component';
import request from 'your-request-library';
import React from 'react';
import {shallow} from 'enzyme';
import Chance from 'chance';
import chai, {expect} from 'chai';
import sinon from 'sinon';
import sinonChai from 'sinon-chai';
@alopes
alopes / components.jsx
Created Jul 20, 2016
React Component variations
View components.jsx
// Stateful component
class Stateful extends Component {
render () {
return <div>Hello Cmp1: stateful</div>;
}
}
// Pure stateful with disabled updates
class Pure extends Component {
shouldComponentUpdate() {
return false;
@alopes
alopes / letsencrypt-jetty.sh
Created May 27, 2016 — forked from xkr47/letsencrypt-jetty.sh
How to use Letsencrypt certificate & private key with Jetty
View letsencrypt-jetty.sh
# input: fullchain.pem and privkey.pem as generated by the "letsencrypt-auto" script when run with
# the "auth" aka "certonly" subcommand
# convert certificate chain + private key to the PKCS#12 file format
openssl pkcs12 -export -out keystore.pkcs12 -in fullchain.pem -inkey privkey.pem
# convert PKCS#12 file into Java keystore format
keytool -importkeystore -srckeystore keystore.pkcs12 -srcstoretype PKCS12 -destkeystore keystore.jks
# don't need the PKCS#12 file anymore
View ready.js
function init() {
}
if (document.readyState != 'loading') init();
else document.addEventListener('DOMContentLoaded', init);
@alopes
alopes / lync.js
Last active Mar 3, 2016
Subscribing to a user presence status using Lync and Sharepoint.
View lync.js
/* eslint new-cap: [2, {"capIsNewExceptions": ["IMNRC"]}] */
// CustomEvent Polyfill
(() => {
if (typeof window.CustomEvent === 'function') {
return false;
}
function CustomEvent(event, params) {
const eventParams = params || { bubbles: false, cancelable: false, detail: undefined };
@alopes
alopes / script.txt
Created Feb 12, 2016
How to create a .p12 from a .pem
View script.txt
openssl pkcs12 -export -in cert.pem -inkey privkey.pem -out cert_and_key.p12 -name tomcat -CAfile chain.pem -caname root
@alopes
alopes / component.js
Last active Aug 5, 2017
jasmine's spyOn() + React.js + ES6
View component.js
import React from 'react';
import _ from 'lodash';
import PubSub from 'pubsub-js';
class Example extends React.Component{
bar(e){
console.log('Bar called')
}
render() {
return(
View getChildContext.js
var A = React.createClass({
childContextTypes: {
name: React.PropTypes.string.isRequired
},
getChildContext: function() {
return { name: "Jonas" };
},