Skip to content

Instantly share code, notes, and snippets.

View romanonthego's full-sized avatar
🥑
avocadoing

Roman Dubinin romanonthego

🥑
avocadoing
View GitHub Profile
require 'rubygems'
require 'bundler'
Bundler.require
require './application'
namespace :assets do
desc 'compile assets'
task :compile => [:compile_js, :compile_css] do
end
# You could do it before, after save or in any place you want
before_save do
# build i file if you want to check something with it first
file = @api.file(self."#{file_attribute}")
if file.something ...
url = file.cdn_url
end
# or use bare url widget passed to you from web form
url = self."#{file_attribute}"
# You could do it before, after save or in any place you want
before_save do
file = self.file #or group, or that ever your attribute is called
# it is important to wrap it up in case remote call fails for any reason
begin
response = file.copy true, "#{target}"
# {
# "url" : "http://..."
# }
const background = require('./assets/background.png')
// ...
{
//...
render: function() {
return (
<div>
<img src={background} />
<img src={background + '-/resize/600x/-/blur/10/-/mirror/-/format/jpg/-/quality/best/-/progressive/yes/'}>
</div>
// background.styl
.background
background-image: url('./assets/background.png')
.smallFlipedAndBluredBackground
background-image: url('./assets/img.jpg?operations=/-/resize/600x/-/blur/10/-/mirror/-/format/jpg/-/quality/best/-/progressive/yes/')
// CSS bundle output:
// => .background {
loaders: [
{test: /\.(jpg|png|gif|otf|ttf|eot|mp4|webm)$/, loader: 'file?name=[name]@[hash].[ext]'},
]
// require('./assets/background.jpg')
//
// => "/_assets/[email protected]" or something like this.
loaders: [
{
test: /\.(jpg|png|gif|otf|ttf|eot|mp4|webm)(\?.*)?$/, // this ugly thing here for operations query support
loader: 'uploadcare',
query: {
publicKey: 'demopublickey',
privateKey: 'demoprivatekey',
statsFilePath: path.join(__dirname, 'build', 'uploadcare.json'),
resourcePathDivider: 'app',
},
@romanonthego
romanonthego / eslint.js
Created May 25, 2016 12:02
eslit config
module.exports = {
"extends": ["airbnb", "plugin:import/errors"],
"plugins": [
"react",
"import",
],
"parserOptions": {
"ecmaVersion": 6,
"sourceType": "module",
import * as firebase from 'firebase/firebase-node'
export default function importFirebase() {
return Promise.resolve(firebase)
}
export default function importFirebase() {
// dynamic import, will return promise
// magic weback comment to get meaningfull chunkname
return import(/* webpackChunkName: 'firebase' */ 'firebase/firebase-browser')
}