Skip to content

Instantly share code, notes, and snippets.

View malina's full-sized avatar
🌴

Alexandr Shumov malina

🌴
View GitHub Profile
@malina
malina / gist:8645456
Last active January 4, 2016 16:09
No layout for ajax request
layout :set_layout
def set_layout
(request.xhr?) ? false : 'your_layout' # layout is false for ajax requests
end
@malina
malina / posts_controller.rb
Created January 28, 2014 08:19
mongo switch db
def switch_database
Mongoid.override_database("amber1_admin_development")
end
def reset_database
Mongoid.override_database(nil)
end
@malina
malina / session.js
Last active August 29, 2015 13:56
AngularJs
app.factory('Session', function($http) {
var Session = {
data: {},
saveSession: function() { /* save session data to db */ },
updateSession: function() {
/* load data from db */
Session.data = $http.get('session.json').then(function(r) { return r.data;});
}
};
Session.updateSession();
Скопируем ключ на наш рутер, исполюзуя scp:
scp root@your-server.org:/etc/openvpn/static.key /etc/openvpn/static.key
@malina
malina / gist:9801565
Created March 27, 2014 06:34
progress
progress: function (e, data) {
var progress = parseInt(data.loaded / data.total * 100, 10);
$('div.progress-bar', uploadProgressBlock).attr('data-pvalue', progress);
},
@malina
malina / budget.js
Last active August 29, 2015 13:58
sample
wBook.controller('Budget', ['$scope', '$http', 'FlashService' , function($scope, $http, FlashService) {
$scope.cats = [{category: 'bride', title: 'Для невесты' } , {category: 'groom', title: 'Для жениха'} , {category: 'banquet', title: 'Банкет'}, {category: 'fun', title: 'Развлечения'},{category: 'decor', title: 'На оформление'}, {category: 'transport', title: 'На транспорт'}, {category: 'other', title: 'Прочее'}];
$scope.current_category = 'bride';
$scope.counts = [];
$scope.totals = [];
$scope.template = {};
$scope.flash = '';
$scope.topp = '';
$scope.url = window.location;
$scope.inprogress = '';
@malina
malina / app.js
Last active August 29, 2015 13:58
debounce
app.directive('changeTimeout', function() {
return {
require: 'ngModel',
link: function(scope, elem, attr, ctrl) {
if (!attr.ngChange) {
throw new TypeError('ng-change directive not present');
}
angular.forEach(ctrl.$viewChangeListeners, function(listener, index) {
ctrl.$viewChangeListeners[index] = _.debounce(function() {
@malina
malina / warior.rb
Last active August 29, 2015 13:59
warior
class Player
def play_turn(warrior)
if warrior.feel.empty? and warrior.health > 10
warrior.walk!(:forward)
else
if warrior.health < 10
#warrior.walk!(:backward)
warrior.bind!
else
warrior.attack!

how to disable same origin policy in chrome , for ubuntu users.

vim /usr/share/applications/google-chrome.desktop

Exec=/opt/google/chrome/google-chrome --incognito --disable-web-security

--disable-web-security is the key.

@malina
malina / color.css
Last active August 29, 2015 14:01
color line
.colorgraph {
margin-bottom: 7px;
height: 5px;
border-top: 0;
background: #c4e17f;
border-radius: 5px;
background-image: -webkit-linear-gradient(left, #c4e17f, #c4e17f 12.5%, #f7fdca 12.5%, #f7fdca 25%, #fecf71 25%, #fecf71 37.5%, #f0776c 37.5%, #f0776c 50%, #db9dbe 50%, #db9dbe 62.5%, #c49cde 62.5%, #c49cde 75%, #669ae1 75%, #669ae1 87.5%, #62c2e4 87.5%, #62c2e4);
background-image: -moz-linear-gradient(left, #c4e17f, #c4e17f 12.5%, #f7fdca 12.5%, #f7fdca 25%, #fecf71 25%, #fecf71 37.5%, #f0776c 37.5%, #f0776c 50%, #db9dbe 50%, #db9dbe 62.5%, #c49cde 62.5%, #c49cde 75%, #669ae1 75%, #669ae1 87.5%, #62c2e4 87.5%, #62c2e4);
background-image: -o-linear-gradient(left, #c4e17f, #c4e17f 12.5%, #f7fdca 12.5%, #f7fdca 25%, #fecf71 25%, #fecf71 37.5%, #f0776c 37.5%, #f0776c 50%, #db9dbe 50%, #db9dbe 62.5%, #c49cde 62.5%, #c49cde 75%, #669ae1 75%, #669ae1 87.5%, #62c2e4 87.5%, #62c2e4);
background-image: linear-gradient(to right, #c4e17f, #c4e17f 12.5%, #f7fdca 12.5%, #f7fdca 25%, #fecf71 25%, #fecf71 37.5%, #f0776c 37