Skip to content

Instantly share code, notes, and snippets.

@danil-z
danil-z / gist:9642347
Last active August 29, 2015 13:57
print receipt
- (NSData *)create2InchReceipt
{
User *user = [User getInstance];
NSMutableData *commands = [[NSMutableData alloc] init];
[commands appendBytes:"\x1d\x57\x80\x31"
length:sizeof("\x1d\x57\x80\x31") - 1]; // Page Area Setting <GS> <W> nL nH (nL = 128, nH = 1)
[commands appendBytes:"\x1b\x61\x01"
@danil-z
danil-z / primus_jwt.js
Created January 24, 2015 20:15
primus jwt
'use strict';
var Primus = require('primus.io'),
authParser = require('parse-bearer-token'),
config = require('../../../config'),
debug = require('debug')('myprimus'),
jwt = require('jsonwebtoken');
function authCheck(token, req, done){
jwt.verify(token, config.jwt_secret, function(err, decoded) {
if (err) {
@danil-z
danil-z / brew.rb
Last active August 29, 2015 14:26 — forked from royingantaginting/brew.rb
Brew formula to install oclint version 0.8.1 or 0.9.dev.02251e4
require 'formula'
class Oclint < Formula
homepage 'http://oclint.org'
url 'http://archives.oclint.org/releases/0.8/oclint-0.8.1-x86_64-darwin-14.0.0.tar.gz'
version '0.8.1'
sha1 'c96d712c5b73e04eebb57c3a97dec2b4ecbb9ed4'
devel do
url 'http://archives.oclint.org/nightly/oclint-0.9.dev.603daa8-x86_64-darwin-14.4.0.tar.gz'
@danil-z
danil-z / oclint-json-compilation-database-parallel
Last active August 29, 2015 14:26 — forked from tommeier/oclint-json-compilation-database-parallel
oclint-json-compilation-database with parallel execution
#!/usr/bin/env python
# Test run with parallel
import os
import platform
import json
import argparse
import re
import subprocess
import sys
@danil-z
danil-z / netzke_columns
Created January 20, 2011 09:45
how to send id instead of title
class SchedulePanel < Netzke::Basepack::BorderLayoutPanel
js_property :header, false
def configuration
school_id = super[:school_id] || component_session[:selected_school_id].to_i
component_session[:selected_school_id] = school_id
subjects_store = Subject.order(:title).all.collect {|c|[c.id,c.title]}
school = School.find(school_id)
classroom_store = school.classrooms.order(:number,:letter).collect {|c|[c.id,c.title]}
period_store = school.type_period.periods.order(:title).collect {|c|[c.id,c.title]}
teacher_store = school.teachers.order(:full_name).map(&:full_name)
@danil-z
danil-z / tabpanel
Created January 30, 2011 11:55
tabpanel.load
class JournalPanel < Netzke::Basepack::BorderLayoutPanel
js_property :header, false
def configuration
school_id = super[:school_id] || component_session[:selected_school_id].to_i
component_session[:selected_school_id] = school_id
school = School.find(school_id)
classroom_store = school.classrooms.order(:number,:letter).collect {|c|[c.id,c.title]}
super.merge(
:tbar => [{xtype: 'tbtext', :text => "#{I18n.t(:journal)} - #{school.title}, #{I18n.t('activerecord.attributes.classroom.title')}: "}, ' ',
{:name => :classroom, :id => :classroom, :xtype => :combo, :editable => false, :trigger_action => :all,
@danil-z
danil-z / JournalSubjectTabPanel.rb
Created March 9, 2011 20:04
components in session
module Blackbumer
class JournalSubjectTabPanel < Netzke::Base
js_base_class "Ext.TabPanel"
def final_config
tabs = stored_tabs.map { |tab| {:layout => :fit, :name => tab[:name], :title => tab[:title], :items => [ tab[:name].to_sym.component]} } || []
orig = super
orig.merge(
:items => tabs
)
end
class ScheduleGrid < Netzke::Basepack::GridPanel
#....
# i think it's too annoing click "add row" button if you add many rows in grid
# this addition to gridpanel allow you add a row automaticaly
# when you finished edit last row and hit tab or enter
js_method :walk_cells, <<-JS
function(row, col, step, fn, scope) {
var cell = #{js_full_class_name}.superclass.walkCells.apply(this, arguments);
if (!cell&&step>0) {
@danil-z
danil-z / simple_app.rb
Created August 8, 2011 14:02
simple_app bug
class VoipRateApp < Netzke::Basepack::SimpleApp
def configuration
orig = super
orig.merge(:items => [{
:region => :center,
:class_name => "Basepack::GridPanel",
:model => "Rate",
:enable_edit_in_form => false,
:rows_per_page => 50,
@danil-z
danil-z / dashboard.rb
Created September 1, 2011 19:33
app/components/dashboard.rb
class Dashboard < Netzke::Base
ex = Netzke::Core.ext_path.join("examples/desktop/js")
js_include ex.join("Desktop.js"), ex.join("App.js") , ex.join("FitAllLayout.js"), ex.join("Module.js")
js_include ex.join("ShortcutModel.js"), ex.join("StartMenu.js"), ex.join("TaskBar.js"), ex.join("Wallpaper.js")
js_base_class "Ext.ux.desktop.App"
js_mixin :main
end