Skip to content

Instantly share code, notes, and snippets.

View sashadev-sky's full-sized avatar

sashadev-sky

  • New York, NY
View GitHub Profile
FILE SPACING:
# double space a file
sed G
# double space a file which already has blank lines in it. Output file
# should contain no more than one blank line between lines of text.
sed '/^$/d;G'
**Error:**
3.1) Failure/Error: @service = @fastly.create_service(:name => name)
Fastly::Error:
{"msg":"Bad request","detail":"Exceeding max_total_services: 10"}
**Solution**
```
$ rails c
@sashadev-sky
sashadev-sky / gist:4c63649309e9d121570731d9f832cef5
Created February 6, 2020 21:05
Export data to CSV file from Rails console
```
require 'csv'
file = "#{Rails.root}/public/user_data.csv"
products = Product.order(:first_name)
headers = ["Product ID", "Name", "Price", "Description"]
CSV.open(file, 'w', write_headers: true, headers: headers) do |writer|
```
var jqry = document.createElement('script');
jqry.src = "https://code.jquery.com/jquery-3.3.1.min.js";
document.getElementsByTagName('head')[0].appendChild(jqry);
```
Now `$` and all the other good stuff will be available
## Rendering with status and location headers:
All renders take the :status and :location options and turn them into headers. They can even be used together:
```Ruby
render :xml => post.to_xml, :status => :created, :location => post_url(post)
```
Note that the :status option accepts not only an HTTP status code (such as 500),
but also a symbol representing that code (such as :created), if that makes more sense to you.
refile problem - need to use downgraded bundler version to install gems
```Bash
$ gem install bundler -v 2.0.1
$ bundle _2.0.1_ install
```
$ ls -lah
$ sudo chown -R <username> <directory_name>
@sashadev-sky
sashadev-sky / fork forced sync
Created September 27, 2019 13:43 — forked from glennblock/fork forced sync
Force your forked repo to be the same as upstream.
git fetch upstream
git reset --hard upstream/master
@sashadev-sky
sashadev-sky / fork forced sync
Created September 27, 2019 13:43 — forked from glennblock/fork forced sync
Force your forked repo to be the same as upstream.
git fetch upstream
git reset --hard upstream/master
@sashadev-sky
sashadev-sky / gist:dd5c430654dd69c4ba5f295a1e8a0c44
Created June 10, 2019 20:12
L.DomEvent extended touch support for IE and Windows
import * as DomEvent from './DomEvent';
import * as Util from '../core/Util';
import * as Browser from '../core/Browser';
/*
* Extends L.DomEvent to provide touch support for Internet Explorer and Windows-based devices.
*/
var POINTER_DOWN = Browser.msPointer ? 'MSPointerDown' : 'pointerdown';