Skip to content

Instantly share code, notes, and snippets.

from random import randint
import kafka
from kafka import KafkaConsumer
BOOTSTRAP_SERVERS = '127.0.0.1:9092'
topic_name = 'test_topic' + str(randint(0, pow(10, 10)))
print(topic_name)
@rinatio
rinatio / gist:f22fd508bfba28eedbb7
Created June 25, 2014 12:17
AngularJS $q promise resolved flag
'use strict';
angular.module('testQDecorator', [])
.config(function($provide) {
$provide.decorator('$q', function($delegate) {
function decoratePromise(promise) {
var then = promise.then;
promise.resolved = false;
promise.finally(function() {
promise.resolved = true;
@rinatio
rinatio / gist:cf2fb1fdd501c6ee206f
Last active August 29, 2015 14:03
AngularJS $q resolved
angular.module('testQDecorator', [])
.config(function($provide) {
$provide.decorator('$q', function($delegate) {
function decoratePromise(promise) {
promise.resolved = false;
promise.finally(function() {
promise.resolved = true;
});
return promise;
}
<html>
<head>
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
<script src="//code.highcharts.com/highcharts.js"></script>
<script>
var chart, el;
window.onload = function() {
el = document.getElementById('chart');
};
@rinatio
rinatio / config.rb
Last active June 15, 2016 19:43
Simple capistrano config.rb for yii/php app
# for more information look at help.github.com/capistrano/
set :application, "yii2-app-basic"
server "example.com", :web # your server address or IP
set :user, "username" # your username for ssh
set :use_sudo, false
# set the remote directory you're going to deploy to
set :deploy_to, "/home/#{user}/www/#{application}"
# disable rails specific normalize_assets property
@rinatio
rinatio / composer.json
Created July 11, 2013 21:20
Yii2 composer.json example
{
"repositories" : [
{
"type": "package",
"package": {
"name": "yiisoft/yii2",
"version": "master",
"source": {
"type": "git",
"url": "https://github.com/yiisoft/yii2.git",
@rinatio
rinatio / simple.js
Created June 15, 2013 00:03
Simple Jasmine Tests Reuse Example
define([
'jasmine'
], function() {
describe('Simple Test', function() {
var view, context = {};
beforeEach(function() {
view = 1;
context.view = view;
});
$db = $this->getContext()->getDB();
$dbConf = $this->getContext()->getConf()->database;
$dbh = new PDO("mysql:host=$dbConf->host;dbname=$dbConf->database", $dbConf->username, $dbConf->password);
$sql = "update runresults set report_html = :report where id = :id";
$q = $dbh->prepare($sql);
$q->execute(array(
':report'=>gzencode('hello'),
':id'=> 1052
));
@rinatio
rinatio / _hover_info
Created May 24, 2013 06:52
Simple hover info with css
.hover-info {
$pd: 20px; // Padding
$bd: 1px; // Border width
$bdr: 8px; // Border radius
$bdc: rgba(0, 0, 0, 0.1); // Border color
$bsh: 2px 2px 2px rgba(0, 0, 0, 0.2); // Box shadow
.hover-details {
display: none;
}
<?php
class SetRoleCommand extends CConsoleCommand
{
public function actionIndex($role, $userId)
{
$auth = Yii::app()->authManager;
$roles = $auth->getRoles();
if (!array_key_exists($role, $roles)) {
$auth->createRole($role);