Skip to content

Instantly share code, notes, and snippets.

View MirzaLeka's full-sized avatar
:octocat:

Mirza Leka MirzaLeka

:octocat:
View GitHub Profile
@matthieua
matthieua / Jasmine: Cheatsheet
Created June 7, 2012 03:04
Jasmine: Cheatsheet
// Jasmine Cheatsheet
// Resources
https://github.com/pivotal/jasmine-ajax //make ajax testing fun
http://sinonjs.org/ //stubing framework
http://johnbintz.github.com/jasmine-headless-webkit/ //headless testing
https://github.com/creynders/grunt-jasmine-task //headless testing
// Use guard-jasmine
gem "guard"
@6174
6174 / Random-string
Created July 23, 2013 13:36
Generate a random string in JavaScript In a short and fast way!
//http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript
Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15);
@mikaelbr
mikaelbr / destructuring.js
Last active April 25, 2024 13:21
Complete collection of JavaScript destructuring. Runnable demos and slides about the same topic: http://git.mikaelb.net/presentations/bartjs/destructuring
// === Arrays
var [a, b] = [1, 2];
console.log(a, b);
//=> 1 2
// Use from functions, only select from pattern
var foo = () => [1, 2, 3];
@alexanderGugel
alexanderGugel / gist:f3e8e82b606dac9624b4
Created November 10, 2014 22:07
Node.JS Redis in production
// Port, host and auth token of Redis server might be defined as environment
// variables. If not, fall back to defaults.
var redisPort = process.env.REDIS_PORT || 6379,
redisHost = process.env.REDIS_HOST || '127.0.0.1',
redisAuth = process.env.REDIS_AUTH || null,
redis = require('redis');
// Since we are waiting for the error event, we don't have to check for errors
// individually after each Redis command.
var onError = function (error) {
@adrianhall
adrianhall / .eslintrc.js
Last active April 29, 2024 15:01
A sample .eslintrc file
var OFF = 0, WARN = 1, ERROR = 2;
module.exports = exports = {
"env": {
"es6": true
},
"ecmaFeatures": {
// env=es6 doesn't include modules, which we are using
"modules": true
@azz
azz / 1-reactive-knockout.js
Last active July 22, 2023 08:20
Extensions to Knockout and RxJS to allow observable conversion.
'use strict';
// Prototypal extensions to knockout and RxJS to fascilitate conversion.
// based on <http://bit.ly/226Yj2o>
import ko from 'knockout';
import Rx from 'rx';
/**
* knockout.subscribable to Rx.Observable
@jschwarzwalder
jschwarzwalder / discord-bot-post-message.py
Created June 4, 2018 21:33 — forked from ianklatzco/discord-bot-post-message.py
sends messages to a discord channel using a bot via http POST
# post a message to discord api via a bot
# bot must be added to the server and have write access to the channel
# you may need to connect with a websocket the first time you run the bot
# use a library like discord.py to do so
import requests
import json
channelID = "your_id_goes_here" # enable dev mode on discord, right-click on the channel, copy ID
botToken = "your_token_here" # get from the bot page. must be a bot, not a discord app
@Ciantic
Ciantic / example-typeorm-jest.test.ts
Created April 16, 2019 17:50
Example of testing TypeOrm with Jest and Sqlite in-memory database
import { createConnection, getConnection, Entity, getRepository } from "typeorm";
import { PrimaryGeneratedColumn, Column } from "typeorm";
@Entity()
export class MyEntity {
@PrimaryGeneratedColumn()
id?: number;
@Column()
name?: string;
@bradtraversy
bradtraversy / node_nginx_ssl.md
Last active June 29, 2024 21:53
Node app deploy with nginx & SSL

Node.js Deployment

Steps to deploy a Node.js app to DigitalOcean using PM2, NGINX as a reverse proxy and an SSL from LetsEncrypt

1. Sign up for Digital Ocean

If you use the referal link below, you get $10 free (1 or 2 months) https://m.do.co/c/5424d440c63a

2. Create a droplet and log in via ssh

I will be using the root user, but would suggest creating a new user

@irfanbaigse
irfanbaigse / hijri-date-sample.js
Created October 24, 2019 12:40
convert Gregorian to Hijri date in javascript
import { gregorianToJulian, julianToHijri } from './hijri-util-date.js';
/**
* Gregorian to Hijri
* * First convert to Julian
* * then convert to hijri
*/
const futureDate = dayjs('2019-10-24').add(1, 'year');
// .format('YYYY-MM-DD');
const y = futureDate.year();
const d = futureDate.day();