Skip to content

Instantly share code, notes, and snippets.

@alexanderisora
alexanderisora / finishJson5.ts
Created May 11, 2023 15:28
function to complete an unfinished JSON.
export const finishJson5 = (unfinishedJson5: string) => {
let stack = [];
let inDoubleQuotes = false;
let inSingleQuotes = false;
let inSingleLineComment = false;
for (let i = 0; i < unfinishedJson5.length; i++) {
const currentChar = unfinishedJson5[i];
const nextChar = unfinishedJson5[i + 1];
let prevChar;
[
{"english": "english", "native": "English", "flag": "🇺🇸🇬🇧", "code": "en"},
{"english": "chinese", "native": "Zhongwen", "flag": "🇨🇳", "code": "zh"},
{"english": "spanish", "native": "Espanol", "flag": "🇪🇸", "code": "es"},
{"english": "french", "native": "Francais", "flag": "🇫🇷", "code": "fr"},
{"english": "japanese", "native": "Nihongo", "flag": "🇯🇵", "code": "ja"},
{"english": "korean", "native": "Hangugeo", "flag": "🇰🇷", "code": "ko"},
{"english": "german", "native": "Deutsch", "flag": "🇩🇪", "code": "de"},
{"english": "dutch", "native": "Nederlands", "flag": "🇳🇱", "code": "nl"},
{"english": "portuguese", "native": "Portugues", "flag": "🇵🇹🇧🇷", "code": "pt"},
@kpavlovsky
kpavlovsky / settings.py
Last active November 9, 2023 03:40
Nginx Cache Setup for Django Site. Uses Django Dummy Cache Backend by default to set required Cache-Control Headers for downstream Nginx Cache
REDIS_URL = os.getenv('REDIS_URL', 'redis://localhost:6379')
CACHES = {
"redis": {
"BACKEND": "django_redis.cache.RedisCache",
"LOCATION": REDIS_URL,
"OPTIONS": {
"CLIENT_CLASS": "django_redis.client.DefaultClient",
}
},
"default": {
<html>
<head>
<title>Authentication Example</title>
</head>
<body>
<form>
<div>
<input id="email" type="text" placeholder="Email...">
@kovshenin
kovshenin / subscribers-count.php
Created November 19, 2015 13:03
Get subscribers count via the MailChimp API.
<?php
/**
* Get subscribers count via the MailChimp API.
*/
function mailchimp_get_subscribers_count() {
$cache_key = 'mailchimp-subscribers';
$api_key = '';
$username = '';
$dc = '';
$list_id = '';
@koistya
koistya / App.js
Last active June 8, 2022 09:55
How to add `onscroll` event in ReactJS component
import React from 'react';
let lastScrollY = 0;
let ticking = false;
class App extends React.Component {
componentDidMount() {
window.addEventListener('scroll', this.handleScroll, true);
}
@cmbaughman
cmbaughman / GetRSSFeed.js
Created March 5, 2014 16:02
Parse RSS feed as JSON from client using Google API
var rssUrl = "http://www.exploit-db.com/rss.xml";
function parseRSS(url, callback) {
$.ajax({
url: document.location.protocol + '//ajax.googleapis.com/ajax/services/feed/load?v=1.0&num=10&callback=?&q=' + encodeURIComponent(url),
dataType: 'json',
success: function(data) {
callback(data.responseData.feed.entries);
}
});
}
@lancejpollard
lancejpollard / meta-tags.md
Created March 5, 2012 13:54
Complete List of HTML Meta Tags

Copied from http://code.lancepollard.com/complete-list-of-html-meta-tags/

Basic HTML Meta Tags

<meta name="keywords" content="your, tags"/>
<meta name="description" content="150 words"/>
<meta name="subject" content="your website's subject">
<meta name="copyright"content="company name">
<meta name="language" content="ES">
@artero
artero / launch_sublime_from_terminal.markdown
Last active January 25, 2024 16:57 — forked from olivierlacan/launch_sublime_from_terminal.markdown
Launch Sublime Text 2 from the Mac OS X Terminal

Launch Sublime Text 2 from the Mac OS X Terminal

Sublime Text 2 ships with a CLI called subl (why not "sublime", go figure). This utility is hidden in the following folder (assuming you installed Sublime in /Applications like normal folk. If this following line opens Sublime Text for you, then bingo, you're ready.

open /Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/subl

You can find more (official) details about subl here: http://www.sublimetext.com/docs/2/osx_command_line.html

Installation

<!DOCTYPE html>
<html>
<head>
<title>jQuery Templating Demo</title>
<style type="text/css">
html {
background:#f3f3f3;
font: 13px/1.5 helvetica, arial, san-serif;
}
ul {