Skip to content

Instantly share code, notes, and snippets.

@ilyazub
ilyazub / upgrade_jasmine_specs.rb
Created Feb 14, 2014
Rake task for upgrading Jasmine specs from 1.3 to 2.0.
View upgrade_jasmine_specs.rb
desc "Upgrade Jasmine specs to 2.0 syntax"
namespace :jasmine do
task :upgrade_specs do
Dir.glob('spec/javascripts/units/**/*_spec.js.coffee') do |filename|
specs = File.read(filename)
specs = specs.gsub('.andReturn', '.and.returnValue')
specs = specs.gsub('.andCallFake', '.and.callFake')
specs = specs.gsub('.andCallThrough', '.and.callThrough')
@ilyazub
ilyazub / represent_matcher.rb
Last active May 17, 2019
RSpec matcher for grape-entity
View represent_matcher.rb
# Alternative: https://github.com/agileanimal/grape-entity-matchers
RSpec::Matchers.define :represent do |expected|
match do |actual|
exposes? && aliases? && has_presenter? && has_runtime_exposure?
end
chain :as do |as_alias|
@as_alias = as_alias
end
@ilyazub
ilyazub / excel_xml_spreadsheet_example.md
Last active May 24, 2020
Excel 2003 XML Spreadsheet example
View excel_xml_spreadsheet_example.md

Excel 2003 XML Spreadsheet example

Example

image

spreadsheet.xml

Solved errors

Problem During Load because of wrong ss:ExpandedRowCount.

@ilyazub
ilyazub / rake_ssh_deploy.md
Last active Aug 29, 2015
Rake SSH deployment
View rake_ssh_deploy.md

Rake SSH deployment

Usage

Set up deployment folder

bundle exec rake deploy:setup

Update code and restart server

@ilyazub
ilyazub / README.md
Last active Dec 19, 2016
Add missing require() calls and module.exports statements
View README.md

Add missing require() calls and module.exports statements

npm run codemode:addMissingRequires

Find javascript files that are changed after creation of the new branch and run script placed in requireUndefined.js. It uses ESLint programmatic API.

codemode:addModuleExports

Find all javascripts inside app/components, filter by the lack of module.exports and apply jscodeshift transform placed in addModuleExports.js.

@ilyazub
ilyazub / memory_usage.log
Created Aug 16, 2017
Spritesmith memory leak
View memory_usage.log
{"rss":54697984,"heapTotal":36393760,"heapUsed":21949752}
{"rss":620531712,"heapTotal":65287968,"heapUsed":29065104}
{"rss":646225920,"heapTotal":64256032,"heapUsed":28251352}
{"rss":647573504,"heapTotal":64256032,"heapUsed":28290648}
{"rss":650907648,"heapTotal":64256032,"heapUsed":28326320}
{"rss":654422016,"heapTotal":64256032,"heapUsed":28348720}
{"rss":657559552,"heapTotal":64256032,"heapUsed":28380736}
{"rss":661073920,"heapTotal":64256032,"heapUsed":28401936}
{"rss":664236032,"heapTotal":64256032,"heapUsed":28430416}
{"rss":667480064,"heapTotal":64256032,"heapUsed":28447160}
@ilyazub
ilyazub / README.md
Created Aug 9, 2019
Reuse `puppeteer` cookies in `tough-cookie` and `got`
View README.md

Reuse puppeteer cookies in tough-cookie and got

This way we can send HTTP requests from the Node.js instead of UI interactions.

Set puppeteer cookies to tough-cookie's CookieJar

const cookies = await page.cookies()
cookies.forEach(
  async cookie => {
    await setCookie(
View Bing_SVG_icon.md
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 35 50" fill="#fff">
  <path d="M35 24.25l-22.177-7.761 4.338 10.82 6.923 3.225H35V24.25z" opacity=".7"/>
  <path d="M10 38.642V3.5L0 0v44.4L10 50l25-14.382V24.25z"/>
</svg>

Preview

bing icon preview

@ilyazub
ilyazub / scrape_google_shopping.py
Last active May 19, 2020
Extract Google Shopping prices via SerpApi
View scrape_google_shopping.py
# https://pypi.org/project/google-search-results
from serpapi.google_search_results import GoogleSearchResults
params = {
"engine": "google",
"q": "Coffee",
"tbm": "shop",
}
client = GoogleSearchResults(params)
@ilyazub
ilyazub / pyproject.toml
Created May 19, 2020
google-search-results via python poetry
View pyproject.toml
[tool.poetry.dependencies]
python = "^3.7"
google-search-results = "^1.8"
[build-system]
requires = ["poetry>=0.12"]
build-backend = "poetry.masonry.api"
You can’t perform that action at this time.