Skip to content

Instantly share code, notes, and snippets.

View Dubiy's full-sized avatar
🔥
code everyday

Gary Dubiy

🔥
code everyday
View GitHub Profile
@Dubiy
Dubiy / categories
Last active February 29, 2016 07:43
{
"categories": [
{
"id": 129,
"name": "STRAIGHT SHANK DRILLS",
"description": null,
"image": "https://s3-eu-west-1.amazonaws.com/somta-files/image/category/Straight-Shank-Drills.jpg"
},
{
"id": 130,
@Dubiy
Dubiy / IssueController.php
Last active February 18, 2016 15:47
edit and save example
<?php
/**
* Edit an Issue entity.
*
* @Route("/edit/{id}", requirements={"id" = "\d+"}, defaults={"id" = 0}, options={"expose": true}, name="issue_edit")
* @ParamConverter("issue", class="AppBundle\Entity\Issue", options={"id"="id"})
* @Template()
* @Method({"GET"})
*/
@Dubiy
Dubiy / IssueEditorCtrl.js
Last active February 16, 2016 12:26
example of editor controller for symfony
angular.module('DemoEkBlog')
.controller('IssueEditorCtrl', ['$rootScope', '$scope', '$http', 'ModalService', 'Upload', '$timeout', IssueEditorCtrl]);
function IssueEditorCtrl($rootScope, $scope, $http, ModalService, Upload, $timeout) {
$rootScope.issue = {};
$scope.categoryId = '';
$scope.init = (data) => {
$scope.colors = data.colors;
$scope.page = data.page;
@Dubiy
Dubiy / edit.html.twig
Last active February 16, 2016 10:31
example editor
{% extends 'AppBundle::baseDashboard.html.twig' %}
{% block body %}
<h1>Issue edit</h1>
<div class="issueEditor" ng-controller="IssueEditorCtrl" ng-init="init({{ initData|json_encode }})" ng-submit="">
<div class="row">
<form name="issueForm" class="render" ng-cloak novalidate>
<div class="issue_title">
<input ng-model="issue.title">
@Dubiy
Dubiy / form_override.html.twig
Created February 16, 2016 08:43
Symfony2 form override to work with AngulaJS
{%- block form_start -%}
{% set method = method|upper %}
{%- if method in ["GET", "POST"] -%}
{% set form_method = method %}
{%- else -%}
{% set form_method = "POST" %}
{%- endif -%}
<form name="{{ name }}" method="{{ form_method|lower }}" action="{{ action }}"{% for attrname, attrvalue in attr %} {{ attrname }}="{{ attrvalue }}"{% endfor %}{% if multipart %} enctype="multipart/form-data"{% endif %}>
{%- if form_method != method -%}
@Dubiy
Dubiy / base.twig.html
Last active February 16, 2016 08:26
Symfony template
<!DOCTYPE html>
<html ng-app="DemoEkBlog">
<head>
<meta charset="UTF-8" />
<title>Demo eKreative Blog CP</title>
<link href="{{ asset('css/vendor.css') }}" media="all" rel="stylesheet" type="text/css" />
<link href="{{ asset('scss/dashboard.css') }}" media="all" rel="stylesheet" type="text/css" />
{% block stylesheets %}{% endblock %}
</head>
<body>
@Dubiy
Dubiy / Angular APP
Last active February 16, 2016 08:14
Angular demo app for symfony2 dashboard
angular.module('DemoEkBlog', [
'ui.bootstrap',
'ui.tinymce',
'angularModalService',
'ngFileUpload'
])
.controller('BaseCtrl', ['$rootScope', BaseCtrl])
;
function BaseCtrl($rootScope) {
@Dubiy
Dubiy / chat-server.conf
Last active May 17, 2017 18:15
apache config for websocket
<VirtualHost *:80>
ServerName chat-backend.testserver.com
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/ [NC]
RewriteCond %{QUERY_STRING} transport=websocket [NC]
RewriteRule /(.*) ws://localhost:3001/$1 [P,L]
ProxyPass / http://localhost:3000/
ProxyPassReverse / http://localhost:3000/
@Dubiy
Dubiy / chat-server.conf
Last active December 3, 2015 16:39
supervisord config example
[program:chat-server]
command=/usr/bin/node /home/ekreative/sites/chat-server/app/index.js
process_name=chat-server-%(process_num)s
numprocs=1
user=ekreative
autostart=true
autorestart=true
stdout_logfile=/var/log/supervisor/chat-server-%(process_num)s.stdout.log
stdout_logfile_backups=3
stderr_logfile=/var/log/supervisor/chat-server-%(process_num)s.stderr.log
var roomId = '95';
var apikey ='90d6bae946306d2dc3cd3c01b56889b8863495744bd3c4ab53adbb2cc546934f3482e1b7fa3ad24dc97842b07e0080aa3ad19fcb106b2f57719e8d9b76b139e7';
var socket = io('/chat');
$('form').submit(function(){
socket.emit('message', {
uuid: 'randomMsgUUID_' + parseInt(Math.random() * 1000000),
body: $('#message').val()
}, function(data) {