Skip to content

Instantly share code, notes, and snippets.

@yan13to
yan13to / gist:01a84212055ce946ef85d712247c9134
Created February 10, 2022 13:24
Patch menu module in redmine ruby
# frozen_string_literal: true
module Helpers
module MenuPatchHelper
# Renders the application main menu
def render_main_menu(project)
if menu_name = controller.current_menu(project)
render_menu(menu_name, project, class: 'nav nav-tabs')
end
end
@yan13to
yan13to / rails http status codes
Created January 26, 2021 02:12 — forked from mlanett/rails http status codes
HTTP status code symbols for Rails
HTTP status code symbols for Rails
Thanks to Cody Fauser for this list of HTTP responce codes and their Ruby on Rails symbol mappings.
Status Code Symbol
1xx Informational
100 :continue
101 :switching_protocols
102 :processing
@yan13to
yan13to / convert
Created February 25, 2020 14:15
Convert video into gif use ffmpeg
ffmpeg -i input_file.flv -vf "fps=10,scale=800:-1:flags=lanczos,split[s0][s1];[s0]palettegen[p];[s1][p]paletteuse" -loop 0 output_file.gif
@yan13to
yan13to / 10_linux
Created January 29, 2020 09:12
/etc/grub.d/10_linux for my dead gpu macbook pro early 2011
#! /bin/sh
set -e
# grub-mkconfig helper script.
# Copyright (C) 2006,2007,2008,2009,2010 Free Software Foundation, Inc.
#
# GRUB is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
@yan13to
yan13to / grub
Created January 29, 2020 09:08
/etc/default/grub for my dead gpu macbook pro early 2011
# If you change this file, run 'update-grub' afterwards to update
# /boot/grub/grub.cfg.
# For full documentation of the options in this file, see:
# info -f grub -n 'Simple configuration'
GRUB_DEFAULT=0
GRUB_TIMEOUT_STYLE=hidden
GRUB_TIMEOUT=0
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash i915.lvds_channel_mode=2 i915.modeset=1 i915.lvds_use_ssc=0"
https://www.youtube.com/watch?v=ELUzf0MDQS0
Hi guys in this video i will be showing how to Use your macbook pro with defekt AMD Radeon GPU using the Intel HD Graphics and Ubuntu OS. I think throw to the garbage a Macbook Pro is not the solution, so after lot of research i came with this Solution, Ubuntu runs awesome as well all the drivers and Functions of the Macbook.
Take a look here to the Steps as well follow the video for detailed steps:
Steps:
1. Download Ubuntu Desktop .iso from the official Ubundo Website
2. Create a booteable USB with the .iso file (use Rufus on windows, Unetbootin on linux)
3. Turn On the Macbook Pro, press ALT key to get into Boot Options
@yan13to
yan13to / bashrc
Last active January 29, 2020 09:12
my common .bashrc
YELLOW="\[\033[0;33m\]"
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}
PS1="${debian_chroot:+($debian_chroot)}\u@\h:\w \$(parse_git_branch)$ "
# Add RVM to PATH for scripting. Make sure this is the last PATH variable change.
export PATH="$PATH:$HOME/.rvm/bin"
@yan13to
yan13to / notifications_channel
Last active January 29, 2020 09:14
Sample importing of actioncable to react component in rails
import React from 'react';
import consumer from '../channels/consumer';
class NotificationsCount extends React.Component {
constructor(props) {
super(props)
this.state = { count: this.props.count }
}
@yan13to
yan13to / vimrc
Last active November 14, 2019 14:14
Vimrc for my development
set encoding=utf-8
set nocompatible
filetype off
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" Plugins
Plugin 'tpope/vim-dispatch'
module AsposeExpoter
Rjb::load(File.join(Rails.root, '/vendor/lib/Aspose.Words.jdk16.jar'), jvmargs=['-Djava.awt.headless=true'])
Rjb::import('com.aspose.words.License').new._invoke('setLicense', 'Ljava.io.InputStream;', Rjb::import('java.io.FileInputStream').new(Rjb::import('java.io.File').new(File.join(Rails.root, '/vendor/lib/Aspose.Words.lic'))))
TempFileRoot = '/tmp'
def to_data_xml_file
fn = File.join(TempFileRoot, "data-xml_#{id}_#{Time.now.to_i}.xml")
open(fn,'w') do |f|
f.write to_xml