Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
Chilling

maksadbek

💭
Chilling
View GitHub Profile
View solarize.sh
#!/bin/sh
#
# Shell script that configures gnome-terminal to use solarized theme
# colors. Written for Ubuntu 11.10, untested on anything else.
#
# Solarized theme: http://ethanschoonover.com/solarized
#
# Adapted from these sources:
# https://gist.github.com/1280177
# http://xorcode.com/guides/solarized-vim-eclipse-ubuntu/
View README.md

Pub/sub with MongoDB and Node.js

Setup:

$ mongo
> use pubsub
> db.createCollection('messages', { capped: true, size: 100000 })
> db.messages.insert({})
View test.js
var mongoose = require('mongoose');
var db = mongoose.createConnection('127.0.0.1', 'test');
// Make schema
var schema = mongoose.Schema({ name: String });
// Create subscribers collection
var subscribers = [];
// Hook `save` post method
View Asterisk.php
<?php
$ghost = 'XXX.XXX.XXX.XXX';
$guser = 'USER_NAME';
$gpwd = 'PASSWORD';
$gdbname = 'DB_NAME';
$db = mysql_connect($ghost, $guser, $gpwd) or die("Could not connect: " . mysql_error());
mysql_select_db ($gdbname, $db) or die (mysql_error($db));
View get_music_from_post.py
#!/usr/bin/python
# -*- coding: utf-8 -*-
import urllib2
import ast
import re
def get_items_of_post(address):
url = "https://api.vk.com/method/wall.getById?posts=" + address + "&extended=1&copy_history_depth=2"
response = urllib2.urlopen(url)
text = response.read()
View redis_pubsub_demo.rb
# Author: Pieter Noordhuis
# Description: Simple demo to showcase Redis PubSub with EventMachine
#
# Update 7 Oct 2010:
# - This example does *not* appear to work with Chrome >=6.0. Apparently,
# the WebSocket protocol implementation in the cramp gem does not work
# well with Chrome's (newer) WebSocket implementation.
#
# Requirements:
# - rubygems: eventmachine, thin, cramp, sinatra, yajl-ruby
View web-server.rb
#!/usr/bin/env ruby
require "webrick"
=begin
WEBrick is a Ruby library that makes it easy to build an HTTP server with Ruby.
It comes with most installations of Ruby by default (it’s part of the standard library),
so you can usually create a basic web/HTTP server with only several lines of code.
The following code creates a generic WEBrick server on the local machine on port 1234,
View subsetsum_dyn.c
#include<stdlb.h>
#include<stdio.h>
int isSubsetSum1(int arr[], int n, int sum)
{
/* The value of subset[i][j] will be true if there is a
subset of set[0..j-1] */
int subset[sum+1][n+1];
int i,j;
View subsetsum_dyn.c
#include<stdlb.h>
#include<stdio.h>
int isSubsetSum1(int arr[], int n, int sum)
{
/* The value of subset[i][j] will be true if there is a
subset of set[0..j-1] */
int subset[sum+1][n+1];
int i,j;
View main.go
package main
import(
"fmt"
"reflect"
)
func main(){
// iterate through the attributes of a Data Model instance
for name, mtype := range attributes(&Dish{}) {