Skip to content

Instantly share code, notes, and snippets.

View bastianwegge's full-sized avatar

Bastian Wegge bastianwegge

  • Crossbow
  • Germany, Münster
  • 11:57 (UTC +01:00)
View GitHub Profile
@bastianwegge
bastianwegge / search.es6.jsx
Created November 9, 2018 08:57
Rails React Autocomplete Search with detailed results
// *************
// This is the frontend search part
// *************
// THE STYLES THAT ARE USED BY THE COMPONENT
// STILL HERE BECAUSE WE POTENTIALLY EXTRACT THEM
let styles = {
item: {
padding: '2px 6px',
cursor: 'default'
@bastianwegge
bastianwegge / gist:129bb9aadb89840dcd832af980c2a068
Last active April 10, 2018 19:53
download script <3 pierre
require 'nokogiri'
require 'httparty'
doc = Nokogiri::XML(HTTParty.get("https://www.google.de").body)
doc.css('link').map{ |a| a.text }.each do |link|
begin
source = HTTParty.get(link).body
url = source.scan(/"https:\/\/.*\.mp4.*"/).first
`wget #{url}`
# p url

Pry Cheat Sheet

Command Line

  • pry -r ./config/app_init_file.rb - load your app into a pry session (look at the file loaded by config.ru)
  • pry -r ./config/environment.rb - load your rails into a pry session

Debugger

// client (client.js)
require('seneca')()
// a local pattern
.add('say:hello', function (msg, respond){ respond(null, {text: "Hi!"}); })
// send any role:math patterns out over the network
// IMPORTANT: must match listening service
.client({ type: 'tcp', pin: 'role:math' })
@bastianwegge
bastianwegge / node_multer_gridfs.js
Created November 10, 2015 01:12
an implementation of the gridfs-stream module by the awesome @mleanos
'use strict';
var mongoose = require('mongoose'),
path = require('path'),
errorHandler = require(path.resolve('./modules/core/server/controllers/errors.server.controller')),
_ = require('lodash');
var Grid = require('gridfs-stream');
Grid.mongo = mongoose.mongo;
var gfs = new Grid(mongoose.connection.db);
var io = require('socket.io/node_modules/socket.io-client');
var querystring = require('querystring');
var http = require('http');
var data = querystring.stringify({
username: 'test',
password: 'testtest'
});
var options = {
@bastianwegge
bastianwegge / gist:6d2b35720e66c31e4a4e
Last active June 14, 2016 17:42
refile file upload using rspec and fixture file upload
describe "post #upload" do
it "image to object" do
container = create :container
file = fixture_file_upload(Rails.root.join('spec/fixtures/files/example.jpg'), 'image/jpeg')
container.attached_image = file
post :upload, container: container.to_param
expect(container.reload.attached_image).to be_present
end
end