Skip to content

Instantly share code, notes, and snippets.

View bludnic's full-sized avatar
:electron:
Developing open-source 🌐

bludnic

:electron:
Developing open-source 🌐
View GitHub Profile
@FbN
FbN / vite.config.js
Last active November 6, 2024 23:56
vite.config.js node built-in polyfills
// yarn add --dev @esbuild-plugins/node-globals-polyfill
import { NodeGlobalsPolyfillPlugin } from '@esbuild-plugins/node-globals-polyfill'
// yarn add --dev @esbuild-plugins/node-modules-polyfill
import { NodeModulesPolyfillPlugin } from '@esbuild-plugins/node-modules-polyfill'
// You don't need to add this to deps, it's included by @esbuild-plugins/node-modules-polyfill
import rollupNodePolyFill from 'rollup-plugin-node-polyfills'
export default {
resolve: {
alias: {
@dimensi
dimensi / auth.test.js
Created April 19, 2018 17:34
Test from microblog on koa.js
import test from 'ava'
import supertest from 'supertest'
process.env.MONGODB_APPLICATION_USER = 'admin'
process.env.MONGODB_APPLICATION_DATABASE = 'admin'
process.env.MONGODB_APPLICATION_PASS = 'qweqwe'
process.env.MONGODB_HOST = 'localhost'
const server = require('../index')
let listen = null
let db = null
@veox
veox / erc20.abi.json
Created January 21, 2018 14:59
ERC20 ABI in JSON format
[
{
"constant": true,
"inputs": [],
"name": "name",
"outputs": [
{
"name": "",
"type": "string"
}
@cferdinandi
cferdinandi / myplugin-media.js
Last active September 24, 2024 20:09
Adding a Media Uploader to a custom metabox
/**
* Load media uploader on pages with our custom metabox
*/
jQuery(document).ready(function($){
'use strict';
// Instantiates the variable that holds the media library frame.
var metaImageFrame;
@Jekis
Jekis / update-postman.sh
Last active March 5, 2019 07:43
Download and install the latest version of Postman for Ubuntu. Create .desktop file.
#!/bin/bash
INSTALL_DIR=/opt/postman
if [ "$(whoami)" != "root" ]
then
echo "Sorry, you are not root. Use sudo!"
exit 1
fi
@mburakerman
mburakerman / package.json
Last active September 26, 2022 17:32
Webpack 4 config.js (SCSS to CSS and Babel) 👌 The Simplest Usage 👌
{
"name": "webpack-sass",
"version": "1.0.0",
"scripts": {
"start": "webpack-dev-server --open --mode development",
"build": "webpack -p"
},
"devDependencies": {
"babel-core": "^6.26.0",
"babel-loader": "^7.1.4",
@ldmarz
ldmarz / http-interceptor.ts
Last active April 17, 2021 12:00
Http interceptor for ionic 3, this allow us to make actions like obtain a JWT token before send the request. Sample of implementation at http://ldmarz.com/ionic3-http-interceptor/
import {Http, RequestOptionsArgs, Response, RequestOptions, ConnectionBackend, Headers} from '@angular/http';
import 'rxjs/add/operator/map';
import { Observable } from 'rxjs/Observable';
import { Storage } from '@ionic/storage';
export class HttpProvider extends Http {
constructor (connectionBackend: ConnectionBackend, requestOptions: RequestOptions, public storage: Storage ) {
super(connectionBackend, requestOptions);
}
@yajra
yajra / axios-401-response-interceptor.js
Last active October 8, 2024 21:22
Axios 401 response interceptor.
// Add a 401 response interceptor
window.axios.interceptors.response.use(function (response) {
return response;
}, function (error) {
if (401 === error.response.status) {
swal({
title: "Session Expired",
text: "Your session has expired. Would you like to be redirected to the login page?",
type: "warning",
showCancelButton: true,
@JesusMurF
JesusMurF / users.js
Created November 16, 2016 10:21
How to encrypt password in Sequelize
import Sequelize from 'sequelize'
import bcrypt from 'bcrypt-nodejs'
import connection from '../config/db'
require('sequelize-isunique-validator')(Sequelize)
let User = connection.define('user', {
firstName: {
type: Sequelize.STRING(50),
allowNull: false,
@JonathanMH
JonathanMH / index.js
Created October 22, 2016 15:07
JSON Web Token Tutorial: Express
// file: index.js
var _ = require("lodash");
var express = require("express");
var bodyParser = require("body-parser");
var jwt = require('jsonwebtoken');
var passport = require("passport");
var passportJWT = require("passport-jwt");