avatar
HackerPie
Backup database and other attachments in ROR
Related Resources rsync :http://rsync.samba.org/ Crontab :http://unixhelp.ed.ac.uk/CGI/man-cgi?crontab+5 “Linux Crontab 定时任务 命令详解” :http://blog.csdn.net/tianlesoftware/article/details/5315039 [rubygem]“backup”:https://github.com/meskyanichi/backup [rubygem]“whenever”:https://github.com/javan/whenever Automatically backup on the remote server: Let’s firstly assumpt: You have a site named “ example.com ”; You can login to it through a username “ deploy ”, and its password is “ password ”; You located the contents of your site in /var/www/example/; Your database server is Mysql , and the database for your site is example…
avatar
HackerPie
Write css codes distinct from different pages
In rails, there is normally a view corresponding to an action. So if you want to do some special styles based on different pages, you can render controller name and action name in your layout file like this: <body class="#{controller_name} #{action_name}"> <!-- Render something --> </body> Let’s assumpt that your current page controller is ProductsController, and your action is index, then you can write your style codes like: .products.index { /* some styles */ }
avatar
HackerPie
Failed to stop or restart Nginx server through serevice command
Many people are accustomed to start a Nginx web server through init scripts and then they can control the state of the server through service command, such as sudo service nginx restart. But sometimes unobvious config error makes the scripts failed to work. Here I will show an error related to pid directive in the config file of nginx, which defaultly located at /opt/nginx/conf/nginx.conf. As ignored by many people, some init scripts assump there is a pid file of nginx located at /var/run/nginx.pid, but in the fact, the default pid file for nginx…
avatar
HackerPie
export/import datas to/from a csv file
今天需要给客户的网站做支持产品数据导出并且更新的功能,所以就涉及到了数据的导入导出了。在经过一番对比之下,果断使用csv格式文件作为数据导入导出的载体。 导出csv文件 与csv文件主要相关的类是CSV,此类在ruby的标准库中被定义,所以只要在代码开头引入相关文件即可: require 'csv' 接着需要创建csv文件,并在其中写入数据: CSV.open "path/to/csv/file", "wb", :col_sep => '|' do |csv| csv << ["one…
avatar
HackerPie
Rails HTTP Status Code to Symbol Mapping
Sometimes you might need to set the HTTP response head with different status to specify the different handled results. You can do this in Rails by add a :status to a rails method such as #respond_with. Here list all the maps: https://gist.github.com/ktkaushik/2405434 Addtionally, you can view all these on your local machine by installing the gem cheat, and see all status codes using command cheat status_codes. All these informations come from internet, the codes file comes from ktkaushik’s gist and other information comes from Cody Fauser’s post
avatar
HackerPie
Delete multiple git remote branches by prefixing all refs with a colon
This article shows how to delete multiple remote branches in Git. git push origin :branch-1 :branch-2 [:other-branches] Remember the colon :
avatar
吕小荣
社交媒体带给我的困惑
朋友之间的责任 没有社交媒体之间,即使我和周围的人有不同的观点。因为吃住在一起,工作在一起,玩在一起,低头不见抬头见,价值观相悖的,却承担了朋友的责任。 有了社交媒体之后,人们可以迅速找到“志同道合”的朋友,哲学,艺术,政治观点,但人与人之间关系也仅限于神交,准确地讲是点赞之交。古代的杜甫饥寒交迫时,高适还寄了些钱给他。网上的伯牙子期,在现实生活中彼此不用承担责任和代价。我生病了,他们…
avatar
BestXTools
好工具周刊(第 13 期): uiverse.io, Neumorphism, cssbuttons, AutoDraw, 网名在线生成器, ...
发现并分享有趣,有创意,免费、好用的工具,每周四发布。由 BestXTools 创作。 上一期内容 | 下一期内容 | 往期内容 | RSS 订阅 | 邮箱订阅 | 微信订阅 | 工具推荐 | 评论 Image from Pixabay 🌈 在线工具 uiverse.io - Universe of UI elements made with HTML & CSS 非常好看的 UI 组件库,全部由 HTML & CSS 制作,代码可以免费复制拿去使用。原名 cssbuttons.io 链接: https://uiverse.io/ Neumorphism/Soft UI CSS shadow generator 新拟物风格 (Neumorphism) CSS 生成器。了解更…
avatar
HackerPie
保持高效与专注的 5 个习惯
日常工作中,可能由于各种各样的信息干扰和诱惑,人在保持高效工作与专注上要面对的挑战其实不小。回顾我自己的一些工作经验和体会,我总结了 5 个能帮助我保持专注和高效的习惯: 拒绝注意力迷宫——不要在电脑上登录微信等常用的 IM 工具,关闭手机通知提醒 异步沟通——直接留言与文档协作 延迟学习——意外的发现放进 Todo list 劳逸结合——让身体舒展,让脑子清理 佩戴耳机,聆听音乐 1. 拒绝注意力迷宫——不要在电脑…
avatar
遇见
1Link.Fun, 第一期: 新的开始
- 在线游戏,找到隐藏的牛  这游戏我很久之前就玩过,这几天又被推到我的信息流里了。 规则很简单,点击开始游戏之后,鼠标(或者手指)在页面上滑动,当你离隐藏的牛的位置越近,牛叫的声音越大。看看你能不能通过听牛的叫声来找到牛的隐藏位置。 - 人民币图样库  中钞(中国印钞造币集团有限公司)官网上列出了从人民币第一套到第五套的高清图样, 另外还有各种纪念钞和…
avatar
BestXTools
好工具周刊(第 14 期): GitHub Profile Page Creator, CodeCaptcha, Q.Link, ASCII banners
发现并分享有趣,有创意,免费、好用的工具,每周四发布。由 BestXTools 创作。 上一期内容 | 往期内容 | RSS 订阅 | 邮箱订阅 | 微信订阅 | 工具推荐 | 评论 🌈 在线工具 GitHub Profile Page Creator 一款在线帮助你生成漂亮的 GitHub 个人主页的工具。 链接: https://github-profile-page-creator.netlify.app/ 源码: https://github.com/iamsatyajit05/GitHub-Profile-Page-Creator CodeCaptcha.io 程序员专用链接分享工具,访问者必须完成随机的编程问题,才能访问你的秘密链接。分享程序员简历,活动邀请、资源…
avatar
电子芥末
tt-focus: 专门为了帮助集中注意力而设计的命令行时间记录器
Command-line time tracker to help focus. tt-focus 有两大特点: 是一个纯命令行程序 主要用途不是记录时间使用情况,而是帮助集中注意力 比如吃饭、睡觉、做运动、娱乐等的时间记录 不适合 使用本软件。 而写作、学习、编程等,就 适合 使用本软件。 安装 本软件使用了 Python 3.10 的新特性,如果你的系统中未安装 Python 3.10, Windows 用户可直接到 Python官网 下载最新版安装即可。 Linux, MacOS 推荐使用 pyenv 或 miniconda 来安装最新版本的 Python。 在有…
avatar
BestXTools
好工具周刊(第 15 期): GitHub Profile Header Generator, Curl UI, Instant Domain Search, Domcomp, 多地 ping、网络延迟测试, 巴别英语, DAREBEE
发现并分享有趣,有创意,免费、好用的工具,每周四发布。由 BestXTools 创作。 上一期内容 | 往期内容 | RSS 订阅 | 邮箱订阅 | 微信订阅 | 工具推荐 | 评论 🌈 在线工具 GitHub Profile Header Generator 一款在线制作 GitHub 个人主页图片的工具。 链接: https://leviarista.github.io/github-profile-header-generator/ 源码: https://github.com/leviarista/github-profile-header-generator Curl UI 一款在线构建 curl 命令参数的工具。 链接: https://www.webutils.app/curl-web-ui Instant Domain Search 一款方便好用的可注册…
avatar
Rei
解决 Rails 7 下 Sass 引用 Font Awesome 的问题
问题 Rails 7 引入了新的前端方案 CSS/JS bundling,让开发者更容易选择适合自己的打包工具。不过新方案要求开发者对 Assets Pipeline 的工作原理有更深的了解,不然会出现各种状况。 例如在引用 Font Awesome 的时候,可能会发生编译了 CSS,但没有编译字体文件的情况,这要怎么解决呢? 解决 假设项目已经配置了 Sass 作为 CSS bundling 方案。 参考 如何从 Webpacker 切换到 CSS/JS bundling 首先安装 Font Awesome: $ yarn add @fortawesome/fontawesome-free 然后在 config…
avatar
Rei
Propshaft 简介
有留意 Rails 更新的人应该会注意到,Rails 7 新增了一个组件选项 Propshaft。 $ rails new --help -a, [--asset-pipeline=ASSET_PIPELINE] # Choose your asset pipeline [options: sprockets (default), propshaft] # Default: sprockets Assets Pipeline 是 Rails 从 3.1 开始内置的前端文件处理机制,它内部实现的库叫做 Sprockets。过去谈论 Assets Pipeline 跟 Sprockets 几乎不做区分,因为两者几乎重叠。而 Rails 7 开始 Assets Pipeline 提供另一个实现,那就是 Propshaft。 Propshaft 的诞生 Sprockets 是一个完整的前端构建工具,它可以对 js,css…
avatar
小白
我学到的HTML(1)
2022年6月1日——2022年6月4日 响应式网页设计 HTML(超文本标记语言)用于创建内容 CSS(级联样式表)用于样式设计 HTML: <h1>开始标签 </h1>结束标签 h1 主标题 h2 副标题 h3,h4,h5,h6... p元素,段落文本的首选元素(p是paragraph) 占位符文本填充空白 lorem ipsum text 注释:<!-- , --> main元素 <main>,</main> img元素添加图片(img元素没有结束标签) src属性指向图片的地址 所有img元素必须有alt属性…
avatar
BestXTools
好工具周刊(第 16 期): JSON Hero, ASCII Art Paint, Puzzle maker, 今天我们来做菜, Tweetlet, ...
发现并分享有趣,有创意,免费、好用的工具,每周四发布。由 BestXTools 创作。 上一期内容 | 往期内容 | RSS 订阅 | 邮箱订阅 | 微信订阅 | 工具推荐 | 评论 🌈 在线工具 JSON Hero 一款超级强大的 JSON 可视化工具。支持多种视图模式、搜索功能、多种数据类型的预览(日期、图片、颜色、链接等)。 链接: https://jsonhero.io/ 源码: https://github.com/jsonhero-io/jsonhero-web ASCII Art Paint 一款在线 ASCII 艺术图像编辑器。 链接: https://kirilllive.github.io/tuesday-js/tools/ascii_paint.html 备用链接…
avatar
小白
我学到的HTML(2)
·a元素实现网页内部跳转 创建内部链接,要将链接的href属性值设置为一个哈希符号"#"加上要内部链接的元素id,同时要将id属性加到链接的元素(id值在一个页面中唯一)。 target="_self",在原页面打开链接; target="_blank",在新页面打开链接,形成父子页面关系。 ·将a嵌套在段落里 <p>View more <a href="https://www.freecatphotoapp.com" target="_blank">cat photos</a> </p> ·用#号来创建链接占位符 href="#" ·给…
avatar
Rei
再见了,Atom
前天惊闻 GitHub 宣布将于年底封存 Atom 编辑器,也就是正式放弃了这个项目,我一时间思绪万千。 我从 2014 年开始使用 Atom 编辑器,至今已经快要 8 年。在 Atom 发布早期,我还为它提过 Issue,可以说见证着它的成长。在使用的过程中,我对 Atom 一直很满意,它伴随我写了很多的代码和博客。 GitHub 放弃这个项目并不让人意外,自从被微软收购后,Atom 的开发便陷入停滞,因为微软旗下有另一个与之竞争…
avatar
HackerPie
Golang 错误处理和日志打印的 5 点建议
Golang 语言语法中,错误处理机制是一个非常有特色的设计,它是基于防御性编程思想的设计。不过今天这篇文章不讨论 Golang 错误处理的语法设计问题,相反,今天想思考的是,Golang 里的错误日志应该怎样处理以及打印比较好。 Golang 中错误处理和日志打印的 5 点建议 使用错误栈的方式; 使用逻辑栈信息,而非代码调用栈; 使用 fmt.Errorf,不用 pkg/errors 第三方模块; 避免使用依赖标准库 fmt 格式化字符串的日志方法; 转换外部错误,基于内部错误…