Skip to content

Instantly share code, notes, and snippets.

@leommoore
leommoore / linux_production_server_setup.md
Last active June 9, 2025 07:28
Linux - Production Server Setup

#Linux - Production Server Setup The principle of running a server in production is to run only what is needed. This keeps the server load to a minimum and reduces the security footprint.

See also http://plusbryan.com/my-first-5-minutes-on-a-server-or-essential-security-for-linux-servers

##Setup the Domain Name (DNS) Point the dns address at the ip address of your server. If the server is rented you should already have a static ip address. If the machine is on your local network you may have to sudo nano /etc/network/interfaces to edit the ip address file. Your setup should be like:

iface eth0 inet static
@leommoore
leommoore / node_running_in_production.md
Last active November 21, 2021 00:50
Node - Running in Production

#Node - Running in Production This gist is based on the excellent post by @hacksparrow which is found at http://www.hacksparrow.com/running-express-js-in-production-mode.html. The main principle is that you want the application to detect that it is running on a production server and to use the production configuration. The way to do this is to set the NODE_ENV=production. To do this you need to do the following:

$ export NODE_ENV=production

But we have a little problem here. The NODE_ENV environment variable will be lost if the server restarts, so it is safer to put it in the .bash_profile file. That way the variable will set again every time the system reboots. You will find the file in your home directory. It's a hidden file, so you can't see it unless you do a ls -la. We will append the export command to the .bash_profile file.

@zero-is-one
zero-is-one / Chinese Learning Word Order
Last active August 15, 2024 22:30
I didn't like the word order that most Chinese learning courses use. This list is the most common used chinese words/phrases and orders them so that no word is shown before its components are shown. It also includes the php files that I used to help generate this list for my own reference.
是 | [shì] to be, 是不是? shìbushì? is (it) or is (it) not?; 是否 shìfǒu whether or not, is (it) or is (it) not?
不 | [bù] not [bú] (used before tone #4); 不是 bú shì isn't
了 | [le] <verb particle marking a new situation or a completed action>; 你来了! Nǐ láile! You have come!; 我累了! Wǒ lèile! I've gotten tired!; 那好了! Nà hǎole! That's OK (now)!; 我只请了一位客人. Wǒ zhǐ qǐngle yí wèi kèren. I invited only one guest. [liǎo] end, finish, settle, dispose of, know clearly, to be able, (=了解 liǎojiě) understand, comprehend; 了了 liǎoliaǒ clearly understand, settle (a debt/etc.), to be intelligent; 了了 liǎole to be over/ended/finnish/settled; 你卖不了! Nǐ mài bùliǎo! You will not be able to sell (it)! [liào] (=瞭 liaò) to survey/watch{Compare with 子 zǐ child}
人 | [rén] person; 人类 rénlèi humankind; 有人吗? yǒu rén ma? Is there anybody here?{Compare with 入 rù enter}
我 | [wǒ] I, me, my; 我们 wǒmen we, us{Compare with 找 zhǎo seek}
在 | [zài] at; 现在 xiànzài now; 存在 cúnzài exist
有 | [yǒu] have, there is; 没有 méiyǒu haven't, there isn't;
@leommoore
leommoore / linux_basic_security.md
Last active December 17, 2015 23:38
Linux - Basic Security

#Linux - Basic Security

##Restricting Remote IP Addresses

It is always a good idea to restrict the access to users and hosts that you trust. To do this you need to:

Edit the /etc/hosts.deny and create a rule

sshd: ALL

# coding=UTF-8
import nltk
from nltk.corpus import brown
# This is a fast and simple noun phrase extractor (based on NLTK)
# Feel free to use it, just keep a link back to this post
# http://thetokenizer.com/2013/05/09/efficient-way-to-extract-the-main-topics-of-a-sentence/
# Create by Shlomi Babluki
# May, 2013
# coding=UTF-8
from __future__ import division
import re
# This is a naive text summarization algorithm
# Created by Shlomi Babluki
# April, 2013
class SummaryTool(object):
@davertron
davertron / editor.html
Last active March 9, 2016 05:09 — forked from minikomi/editor.html
Javascript editor in your browser
data:text/html,
<style type="text/css">
#e {
position:absolute;
top:0;
right:0;
bottom:0;
left:0;
font-size:16px;
}
@ndarville
ndarville / business-models.md
Last active October 9, 2025 17:55
Business models based on the compiled list at http://news.ycombinator.com/item?id=4924647. I find the link very hard to browse, so I made a simple version in Markdown instead.

Business Models

Advertising

Models Examples
Display ads Yahoo!
Search ads Google
@adharris
adharris / postgres_array.go
Created November 28, 2012 19:52
PostgreSQL demo of Array types using Golang
package main
import (
"database/sql"
"errors"
"fmt"
_ "github.com/bmizerany/pq"
"os"
"regexp"
"strings"
@TigorC
TigorC / form_ajax.js
Created August 22, 2012 11:43
Django bootstrap AJAX form
// Для отправки вормы использовать jQuery ajax forms (http://jquery.malsup.com/form/)
// Показывает ошибки формы
function show_form_errors(form, error_json)
{
clear_form_errors(form);
for (name in error_json) {
var elem = form.find('input[name=' + name + '], textarea[name=' + name + ']');
elem.closest('.control-group').addClass('error');
elem.parent().prepend($('<span class="help-inline">*' + error_json[name] + '</span>'));
}