- Download all packages normally from npm or yarn
- Install https://www.npmjs.com/package/node-tgz-downloader to download all the tarballs associated your package-lock.json
- Command is
download-tgz package-lock package-lock.json
this will generate a tarballs/ in the root of your project - Upload the tgz to your private registry by defining first the .npmrc
- Run the script ./npmimport.sh to upload all the tarballs
View serverless-function-reference-formats.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function: | |
foo: | |
handler: index.handler | |
# Ways to reference function in serverless.yml | |
FunctionName: !Sub arn:aws:lambda:${AWS::Region}:${AWS::AccountId}:function:${self:service.name}-${self:provider.stage}-foo | |
FunctionName: !GetAtt FooLambdaFunction.Arn | |
FunctionName: !Sub "${AWS::StackName}-foo" | |
FunctionName: ${self:service.name}-${self:provider.stage}-foo |
View gist:d7d5be86c1516966bdaa7dd2b4151970
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 1) Import this forge.min.js from browser console | |
var script = document.createElement('script');script.src = "https://cdnjs.cloudflare.com/ajax/libs/forge/1.3.1/forge.min.js";document.getElementsByTagName('head')[0].appendChild(script); | |
// 2) Paste this method in browser console | |
function encryptPassword(psd, pem) { | |
try { | |
//using jsencrypt.js | |
/* var encrypt = new JSEncrypt(); | |
encrypt.setPublicKey(publicKey); |
View index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fs = require('fs') | |
const parse = require('csv-parse/lib/sync') | |
const AWS = require('aws-sdk') | |
var credentials = new AWS.SharedIniFileCredentials({ profile: '<aws-profile>' }); | |
AWS.config.update({ | |
region: 'ap-southeast-1', | |
credentials: credentials | |
}); |
View S3.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Download object from S3 | |
aws s3api get-object --bucket {{bucket_name}} --key {{object_from_s3.zip}} {{downloaded_file_name.zip}} | |
// Upload object to S3 | |
aws s3api put-object --bucket {{bucket_name}} --key {{file_name}} --body {{actual_file}} | |
// Delete object from S3 | |
aws s3api delete-object --bucket {{bucket_name}} --key {{file_name}} |
View restart-delayed-job
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
project="myapp" | |
echo "Restarting Background Workers" | |
cd /srv/www/$project/current/ | |
RAILS_ENV=uat bin/delayed_job restart -n 5 |
View Readme.md
View crypt.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Crypt | |
class << self | |
ENCRYPTION_KEY = Rails.application.secrets[:encryption_key] | |
ALGO = 'aes-256-cbc'.freeze | |
def encrypt(value) | |
crypt(:encrypt, value) | |
end |
View A Nuxt.js VPS production deployment.md
Example of deployment process which I use in my Nuxt.js projects. I usually have 3 components running per project: admin-panel SPA, nuxt.js renderer and JSON API.
This manual is relevant for VPS such as DigitalOcean.com or Vultr.com. It's easier to use things like Now for deployment but for most cases VPS gives more flexebillity needed for projects bigger than a landing page.
UPD: This manual now compatible with nuxt@2.3. For older versions deployment, see revision history.
Let's assume that you have entered fresh installation of Ubuntu instance via SSH. Let's rock:
View userAvatar.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* This gist was inspired from https://gist.github.com/homam/8646090 which I wanted to work when uploading an image from | |
* a base64 string. | |
* This code is used in my startup, Zired. | |
* Web: http://zired.io | |
*/ | |
// You can either "yarn add aws-sdk" or "npm i aws-sdk" | |
const AWS = require('aws-sdk') |
View express-server-side-rendering.md
Terminology
- View: Also called a "template", a file that contains markup (like HTML) and optionally additional instructions on how to generate snippets of HTML, such as text interpolation, loops, conditionals, includes, and so on.
- View engine: Also called a "template library" or "templater", ie. a library that implements view functionality, and potentially also a custom language for specifying it (like Pug does).
- HTML templater: A template library that's designed specifically for generating HTML. It understands document structure and thus can provide useful advanced tools like mixins, as well as more secure output escaping (since it can determine the right escaping approach from the context in which a value is used), but it also means that the templater is not useful for anything other than HTML.
- String-based templater: A template library that implements templating logic, but that has no understanding of the content it is generating - it simply concatenates together strings, potenti
NewerOlder