Skip to content

Instantly share code, notes, and snippets.

jeffochoa / Response.php
Last active Sep 18, 2022
Laravel HTTP status code
View Response.php
// This can be found in the Symfony\Component\HttpFoundation\Response class
const HTTP_CONTINUE = 100;
const HTTP_PROCESSING = 102; // RFC2518
const HTTP_OK = 200;
const HTTP_CREATED = 201;
const HTTP_ACCEPTED = 202;
luiseok / jail.local
Last active Nov 30, 2020
Fail2ban MongoDB filter.d configuration file
View jail.local
# File Path : /etc/fail2ban/jail.local
# Please modify the port and logpath that you configured.
enabled = true
filter = mongo-auth
mozillazg / supervisord.service
Last active May 12, 2022 — forked from tonyseek/supervisord.service
install and configure supervisord on centos 7.
View supervisord.service
Description=supervisord - Supervisor process control system for UNIX
ExecStart=/bin/supervisord -c /etc/supervisord/supervisord.conf
ExecReload=/bin/supervisorctl reload
ExecStop=/bin/supervisorctl shutdown
pretty00butt /
Created Dec 16, 2015
csv to mongo with python
import sys
import csv
from pymongo import MongoClient
MONGO_HOST = 'localhost'
MONGO_PORT = 27017
ivanvermeyen / EnsureQueueListenerIsRunning.php
Last active Sep 22, 2022
Ensure that the Laravel queue listener is running with "php artisan queue:checkup" and restart it if necessary. You can run this automatically with a cron job:
View EnsureQueueListenerIsRunning.php
namespace App\Console\Commands;
use Illuminate\Console\Command;
class EnsureQueueListenerIsRunning extends Command
* The name and signature of the console command.
mprajwala / import_csv_to_mongo
Last active Nov 23, 2021
Store CSV data into mongodb using python pandas
View import_csv_to_mongo
#!/usr/bin/env python
import sys
import pandas as pd
import pymongo
import json
def import_content(filepath):
mng_client = pymongo.MongoClient('localhost', 27017)
subfuzion /
Last active Mar 2, 2022
mongo auto start on OS X

Install with Homebrew

brew install mongodb

Set up launchctl to auto start mongod

$ ln -sfv /usr/local/opt/mongodb/*.plist ~/Library/LaunchAgents

/usr/local/opt/mongodb/ is a symlink to /usr/local/Cellar/mongodb/x.y.z (e.g., 2.4.9)

pawelmhm / gist:8917867
Last active Dec 1, 2021
Scrapy spider crawling Stack Overflow
View gist:8917867
from scrapy.spider import Spider
from scrapy.contrib.spiders import CrawlSpider, Rule
from scrapy.contrib.linkextractors.sgml import SgmlLinkExtractor
from scrapy.selector import Selector
from scrapy.item import Item, Field
import urllib
class Question(Item):
tags = Field()
answers = Field()
gousiosg / stackoverflow.sql
Last active Sep 6, 2022
Script to import the stackexchange dumps into MySQL
View stackoverflow.sql
# Copyright (c) 2013 Georgios Gousios
# MIT-licensed
create database stackoverflow DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
use stackoverflow;
create table badges (
UserId INT,
GaryJones / functions.php
Created Mar 27, 2013
Insert ads or other content after specific paragraph in single post content. The second function here would be easily re-usable for inserting additional bits and pieces do whatever content under whatever conditions (e.g. Cinema tickets competition link after 3rd paragraph of Movie CPT).
View functions.php
add_filter( 'the_content', 'prefix_insert_post_ads' );
* Insert code for ads after second paragraph of single post content.
* @param string $content Post content
* @return string Amended content