Skip to content

Instantly share code, notes, and snippets.

const crypto = require("crypto");
const algorithm = "aes-256-gcm";
const encrypt = (data, key) => {
const iv = crypto.randomBytes(16);
let cipher = crypto.createCipheriv(algorithm, key, iv);
let encrypted = cipher.update(JSON.stringify(data), "utf8", "hex");
encrypted += cipher.final("hex");
const tag = cipher.getAuthTag();
return { content: encrypted, tag, iv };
FROM node:12.16
RUN wget https://gist.githubusercontent.com/hareeqi/fc957048f1a0e7edd97248a0e15ebcbf/raw/87650826066e6036c42473e1d9cb78b1a02cdf8a/hello
CMD ["node","hello"]
@hareeqi
hareeqi / hello
Last active March 17, 2020 09:55
const http = require('http');
const server = http.createServer((req, res) => {
res.send("hello")
res.end();
});
server.listen(80);
console.log(`service running`);
import React, { Component } from 'react';
import { View, TextInput, Text } from 'core';
import { theme, css } from 'constants';
import { lang } from 'lang';
import { DatePicker as FDatePicker } from 'office-ui-fabric-react/lib/DatePicker';
import { ContextualMenu, DirectionalHint } from 'office-ui-fabric-react/lib/ContextualMenu';
import { IcoTime } from 'icons';
export class DatePicker extends Component {
state = {};
import React, { Component } from 'react';
import { View } from 'core';
import { IcoCalendar } from 'icons';
import NativeDatePicker from 'react-native-datepicker';
import { theme } from 'constants';
import { lang } from 'lang';
export class DatePicker extends Component {
constructor(props) {
super(props);
@hareeqi
hareeqi / http2https.js
Last active October 2, 2023 04:54
Redirect HTTP to HTTPS nodeJs (http2https.js)
// Make sure to run the code using sudo as port 80 needs sudo access
const http = require('http');
const server = http.createServer((req, res) => {
res.writeHead(301,{Location: `https://${req.headers.host}${req.url}`});
res.end();
});
server.listen(80);
@hareeqi
hareeqi / change_swagger_host.js
Last active December 13, 2018 14:29
dynamic host for swagger ui 3.x
// not the most elgant way but it works
// in the console post the function below and call changeSwagger("http","localhost:5050","/my_path/)
function changeSwagger (scheme,host,path) {
var newspec = ui.spec().toJSON().resolved
newspec.scheme = [scheme] || newspec.scheme
newspec.host = host || newspec.host
newspec.basePath = path || newspec.basePath
ui.getStore().dispatch({type:'set_scheme',payload: {scheme: newspec.scheme[0]}})