Skip to content

Instantly share code, notes, and snippets.

View ghonchesefidi's full-sized avatar

Mohammad Ghonchesefidi ghonchesefidi

View GitHub Profile
@keeguon
keeguon / countries.json
Created April 5, 2012 11:11
A list of countries in JSON
[
{name: 'Afghanistan', code: 'AF'},
{name: 'Åland Islands', code: 'AX'},
{name: 'Albania', code: 'AL'},
{name: 'Algeria', code: 'DZ'},
{name: 'American Samoa', code: 'AS'},
{name: 'AndorrA', code: 'AD'},
{name: 'Angola', code: 'AO'},
{name: 'Anguilla', code: 'AI'},
{name: 'Antarctica', code: 'AQ'},
@pingwping
pingwping / gist:92219a8a1e9d44e1dd8a
Last active March 6, 2023 18:35
Create and update embedded documents with MongoEngine
# REF: http://www.quora.com/How-do-I-create-and-update-embedded-documents-with-MongoEngine
class Comment(EmbeddedDocument):
content = StringField()
name = StringField(max_length=120)
class Post(Document):
title = StringField(max_length=120, required=True)
author = StringField(required=True)
@EvanHerman
EvanHerman / check-if-element-in-viewport-on-scroll.js
Last active May 31, 2023 13:23
Check when an element comes into view (jQuery)
function isOnScreen(elem) {
// if the element doesn't exist, abort
if( elem.length == 0 ) {
return;
}
var $window = jQuery(window)
var viewport_top = $window.scrollTop()
var viewport_height = $window.height()
var viewport_bottom = viewport_top + viewport_height
var $elem = jQuery(elem)
[
"Afghan",
"Albanian",
"Algerian",
"American",
"Andorran",
"Angolan",
"Antiguans",
"Argentinean",
"Armenian",
@cecilemuller
cecilemuller / letsencrypt_2020.md
Last active July 14, 2024 19:55
How to setup Let's Encrypt for Nginx on Ubuntu 18.04 (including IPv6, HTTP/2 and A+ SSL rating)

How to setup Let's Encrypt for Nginx on Ubuntu 18.04 (including IPv6, HTTP/2 and A+ SLL rating)


Virtual hosts

Let's say you want to host domains first.com and second.com.

Create folders for their files:

@shaik2many
shaik2many / javascript-localstorage-expiry.js
Created July 20, 2016 14:07
set timeout for localStorage or sessionStorage
http://apassant.net/2012/01/16/timeout-for-html5-localstorage/
var hours = 24; // Reset when storage is more than 24hours
var now = new Date().getTime();
var setupTime = localStorage.getItem('setupTime');
if (setupTime == null) {
localStorage.setItem('setupTime', now)
} else {
if(now-setupTime > hours*60*60*1000) {
localStorage.clear()
@ziluvatar
ziluvatar / token-generator.js
Last active July 16, 2024 14:46
Example of refreshing tokens with jwt
/**
* Example to refresh tokens using https://github.com/auth0/node-jsonwebtoken
* It was requested to be introduced at as part of the jsonwebtoken library,
* since we feel it does not add too much value but it will add code to mantain
* we won't include it.
*
* I create this gist just to help those who want to auto-refresh JWTs.
*/
const jwt = require('jsonwebtoken');
@bradtraversy
bradtraversy / docker-help.md
Last active July 9, 2024 10:18
Docker Commands, Help & Tips

Docker Commands, Help & Tips

Show commands & management commands

$ docker

Docker version info

@themojilla
themojilla / countries.js
Last active April 17, 2024 11:33
لیست کامل کشورهای جهان - json
export default [
{ name: 'Afghanistan', code: 'AF', name_fa: 'افغانستان' },
{ name: 'land Islands', code: 'AX', name_fa: 'جزایر الند' },
{ name: 'Albania', code: 'AL', name_fa: 'آلبانی' },
{ name: 'Algeria', code: 'DZ', name_fa: 'الجزایر' },
{ name: 'American Samoa', code: 'AS', name_fa: 'ساموآی آمریکا' },
{ name: 'AndorrA', code: 'AD', name_fa: 'آندورا' },
{ name: 'Angola', code: 'AO', name_fa: 'آنگولا' },
{ name: 'Anguilla', code: 'AI', name_fa: 'آنگویلا' },
{ name: 'Antigua and Barbuda', code: 'AG', name_fa: 'آنتیگوآ و باربودا' },
from mongoengine import connect, Document, EmbeddedDocument, \
ReferenceField, EmbeddedDocumentListField, StringField, ObjectIdField
connect() # Connect to `test` database by default
######
# Option1: Using 2 different collections for users and tickets
######
class User(Document):
name = StringField()