Skip to content

Instantly share code, notes, and snippets.

View ramainen's full-sized avatar

Damir Fakhrutdinov ramainen

View GitHub Profile
@ramainen
ramainen / App.js
Last active May 17, 2018 08:16
Примеры интеракций
import React, { Component } from 'react';
import './App.css';
import Titler from './Titler'
import {observer, inject} from 'mobx-react';
@inject("model")
@observer
$(".button").click(function(){
$(".button").vibrate(50);
});
package main
import (
"fmt"
"html"
"log"
"net"
"net/http"
"os"
"runtime"
@ramainen
ramainen / pages.sql
Created January 29, 2015 18:03
pages.sql
CREATE TABLE `pages` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`url` text,
`text` text,
`title` text,
`page_id` int(11) DEFAULT NULL,
`template` varchar(255) DEFAULT NULL,
`type` varchar(255) DEFAULT NULL,
`multi_domain` varchar(255) DEFAULT NULL,
`created_at` datetime DEFAULT NULL,
@ramainen
ramainen / recepy.md
Last active August 29, 2015 14:11
Соус
  1. Жарим мясо на сковороде.
  2. Подкидываем в мясо лук и морковь, обжариваем.
  3. Подкидываем пару столовых ложек муки
  4. Сразу подкидываем пару столовых ложек майонеза и столько же кетчупа
  5. Чайная ложка сахара, соль по вкусу
  6. Заливаем водой, мешаем, чтобы не было комков, тушим. (если мясо готово при обжарке, достаточно дать закипеть)

Готово

@ramainen
ramainen / designer.html
Last active August 29, 2015 14:09
designer
<link rel="import" href="../topeka-elements/avatars.html">
<link rel="import" href="../core-icon/core-icon.html">
<link rel="import" href="../core-field/core-field.html">
<link rel="import" href="../core-input/core-input.html">
<link rel="import" href="../core-icons/core-icons.html">
<link rel="import" href="../core-pages/core-pages.html">
<link rel="import" href="../core-icon-button/core-icon-button.html">
<link rel="import" href="../paper-checkbox/paper-checkbox.html">
<link rel="import" href="../paper-tabs/paper-tabs.html">
<link rel="import" href="../paper-tabs/paper-tab.html">
//Sample I use
socket.on('disconnect', function() {
	if(typeof(socket._room) != 'undefined'){
		for(key in socket._room){
			if(Object.keys(io.sockets.adapter.rooms[socket._room[key]]).length == 0){
				delete io.sockets.adapter.rooms[socket._room[key]];
			}
		}
	}

delete io.sockets.adapter.rooms[socket.id];

Client:

var table_id = 1; // example, python will give this value

var socket = io('http://localhost:3000/table'+table_id');
socket.on('connect', function() {
	console.log('Connected');
	socket.emit('join', "table_"+table_id);
});
@ramainen
ramainen / sample.html
Created September 4, 2014 08:52
myclientcode
<script src="/cms/external/socket.io.js"></script>
<script>var socket = io("http://cloud.doit-cms.ru");socket.emit("register", { userid: "75b0390c23ecef9109e66d0b352a1a66" });</script>
<script>
//бизнес логика
@ramainen
ramainen / gist:514a76743bedbbc7bbf3
Created August 13, 2014 10:54
file download attachment
<?php
function download_file($adress){
$adress = str_replace('+',' ',$adress);
$file = d()->File->where('title = ?',$adress);
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header("Content-Disposition: attachment; filename*=UTF-8''".rawurlencode( $file->title).'.'.$file->ext."");
header('Content-Transfer-Encoding: binary');
header('Expires: 0');