Skip to content

Instantly share code, notes, and snippets.

View jrichardsz's full-sized avatar

JRichardsz jrichardsz

View GitHub Profile
@jrichardsz
jrichardsz / node-and-npm-in-30-seconds.sh
Created December 25, 2017 12:21 — forked from isaacs/node-and-npm-in-30-seconds.sh
Use one of these techniques to install node and npm without having to sudo. Discussed in more detail at http://joyeur.com/2010/12/10/installing-node-and-npm/ Note: npm >=0.3 is *safer* when using sudo.
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc
. ~/.bashrc
mkdir ~/local
mkdir ~/node-latest-install
cd ~/node-latest-install
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1
./configure --prefix=~/local
make install # ok, fine, this step probably takes more than 30 seconds...
curl https://www.npmjs.org/install.sh | sh
@jrichardsz
jrichardsz / package.json
Last active January 24, 2018 22:18
Simple webpack invocation programatically with node.js
{
"name": "webpack",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "node dev-server.js"
},
"author": "JRichardsz",
"license": "MIT",
@jrichardsz
jrichardsz / webpack.server.js
Last active January 24, 2018 23:31
Use middleware with webpack-dev-server and initialize session
// read : https://github.com/webpack/webpack-dev-server/issues/285#issuecomment-145781542
// read : https://github.com/webpack/webpack-dev-server/issues/533
var webpack = require('webpack');
var WebpackDevServer = require('webpack-dev-server');
var config = require("./webpack.nonproduction.config.js");
var express = require('express');
var session = require('express-session');
var compiler = webpack(config);
const app = express();
@jrichardsz
jrichardsz / SecurityServiceImpl.java
Last active February 1, 2018 21:16
@PreAuthorize and hasProtectedAccess
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Service;
@Service
public class SecurityServiceImpl {
private @Autowired HttpServletRequest httpServletRequest;
@jrichardsz
jrichardsz / multiple.module.exports.js
Created February 7, 2018 16:49
Declare multiple module.exports in Node.js
//You can do something like:
module.exports = {
method: function() {},
otherMethod: function() {}
}
//Or even just:
@jrichardsz
jrichardsz / get_store.js
Last active February 8, 2018 20:43
react store client side and server side, https://github.com/reactjs/redux/issues/776
A reasonable alternative solution is to use a module level function that uses an opaque object representing context to retrieve context-specific store instance which would be used like this:
// client-side
var store = require('redux').getStore(window)
// server-side
function handleFoobar(req, res) {
var store = require('redux').getStore(req);
}
@jrichardsz
jrichardsz / Share_props_react_component.js
Created February 8, 2018 23:52
React pass simple ptop to component
<MyComponent someAttribute={data.value} />
const MyComponent = props => {
<p>{props.someAttribute}</p>
};
//https://medium.com/byte-sized-react/handling-data-with-props-in-react-900fdc44a8c
@jrichardsz
jrichardsz / install_update_node.sh
Last active June 18, 2020 13:41
Install or Update node.js
# example of node.js 6.1..5 installation
# easy
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash
nvm install v6.11.5
nvm install v8.11.2
nvm install v10.4.0
# something easy
curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
##############################
# sdout stderr enabled
##############################
mvn_detect() {
maven_version=$(mvn -v)
status=$?
echo $status
}
@jrichardsz
jrichardsz / ffmpeg_video_to_gif.md
Last active September 1, 2021 06:01
Convert video to GIF using ffmpeg

palette

is just a png file of 1x1 pixels dimension.

https://i.ibb.co/DC05bQB/palette.png

origin dimensions and complete video

ffmpeg -i demo.webm -i palette.png -filter_complex "fps=10" demo.gif