Skip to content

Instantly share code, notes, and snippets.

View pkulev's full-sized avatar

Pavel Kulyov pkulev

View GitHub Profile
#include <stdio.h>
typedef struct Point {
int x;
int y;
} Point;
Point *create_point(int x, int y, Point *point)
{
//point = struct Point;
class A(object):
def foo(self):
print(1)
class B(object):
def foo(self):
print(2)
class C(A, B):
@staticmethod
@pkulev
pkulev / migrate-school.py
Last active August 29, 2015 14:28
pshoo
"""School.students migration script."""
from pymongo import MongoClient
conn = MongoClient("mongodb://localhost:27017")
db = conn.school
students = db.students
for student in students.find():
import gridfs
import pymongo
conn = pymongo.MongoClient("mongodb://localhost:27017")
db = conn.test
videos_meta = db.videos_meta
def main():
grid = gridfs.GridFS(db, "videos")
import gridfs
import pymongo
conn = pymongo.MongoClient("mongodb://localhost:27017")
db = conn.test
videos_meta = db.videos_meta
def main():
grid_id = videos_meta.find_one({"filename": "video.mp4"})["grid_id"]
@pkulev
pkulev / a.py
Last active August 26, 2015 17:07
def get_running_os_name(name):
os_map = {
"linux": "linux",
"freebsd": "freebsd",
"openbsd": "openbsd",
"sunos5": "solaris",
"win32": "windows",
"darwin": "osx"}
for start in os_map:
# Andrew Erlichson
# MongoDB
# script to start a sharded environment on localhost
# clean everything up
echo "killing mongod and mongos"
killall mongod
killall mongos
@pkulev
pkulev / ecs_example.py
Created November 19, 2015 10:41 — forked from SpotlightKid/ecs_example.py
Example of plumbing needed to use the ecs package
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import time
from ecs import Component, Entity, EntityManager, System, SystemManager
class MovementSystem(System):
"""Movement system to update position of Movable components."""
#!/usr/bin/python
import argparse
import os
import sys
from subprocess import check_output, CalledProcessError
def parse_args():
parser = argparse.ArgumentParser()
#!/bin/sh -e
PROG="${0##*/}"
usage() {
echo -e "Usage: ${PROG} ACTION FILE\n"
echo " ${PROG} moves or copies FILE to /usr/portage/distfiles and sets proper umask."
echo " ACTION: action {cp, mv}."
echo -e " FILE: path to file.\n"
echo " You mustn't run this script with root privileges."