Skip to content

Instantly share code, notes, and snippets.

View obliviusm's full-sized avatar
🏠
Can't work from home because of russians

Misha Sebalo obliviusm

🏠
Can't work from home because of russians
View GitHub Profile
@obliviusm
obliviusm / rails-jsonb-queries
Created October 10, 2022 18:36 — forked from mankind/rails-jsonb-queries
Ruby on Rails-5 postgresql-9.6 jsonb queries
http://stackoverflow.com/questions/22667401/postgres-json-data-type-rails-query
http://stackoverflow.com/questions/40702813/query-on-postgres-json-array-field-in-rails
#payload: [{"kind"=>"person"}]
Segment.where("payload @> ?", [{kind: "person"}].to_json)
#data: {"interest"=>["music", "movies", "programming"]}
Segment.where("data @> ?", {"interest": ["music", "movies", "programming"]}.to_json)
Segment.where("data #>> '{interest, 1}' = 'movies' ")
Segment.where("jsonb_array_length(data->'interest') > 1")
@obliviusm
obliviusm / gist:e665d79b33d63a6c906a4d61f8755536
Last active September 11, 2020 20:43 — forked from bkimble/gist:1365005
List local memcached keys using Ruby
#!/usr/bin/env ruby
# List all keys stored in memcache.
# Credit to Graham King at http://www.darkcoding.net/software/memcached-list-all-keys/ for the original article on how to get the data from memcache in the first place.
require 'net/telnet'
headings = %w(id expires bytes cache_key)
rows = []
Is the line of code below valid Ruby code? If so, what does it do? Explain your answer.
-> (a) {p a}["Hello world"]
@obliviusm
obliviusm / відео_уроки
Last active March 11, 2020 22:19
відео_уроки
5 кл
Види речень за метою висловлювання. Відеоурок з української мови 5 клас
https://www.youtube.com/watch?v=ofoLBvPjIIo
6кл
числівники https://webpen.com.ua/pages/Morphology_and_spelling/numerals_declination.html
8кл
прикметниик https://webpen.com.ua/pages/Morphology_and_spelling/adjective_grammatically_characteristic.html
@obliviusm
obliviusm / extract_youtube_video.rb
Last active November 2, 2018 15:02
Rails API sample code to get playlist and watch videos
require 'proxy_list_api_client'
class ExtractYoutubeVideo
def initialize(video_id)
@video_id = video_id
end
def perform
extract_video_stream_uri.presence || extract_video_stream_uri(with_proxy: true)
end
import apisauce from 'apisauce'
const create = () => {
const api = apisauce.create({
baseURL: 'https://lyoutube-api-master.herokuapp.com/api/v1',
timeout: 20000,
responseType: 'json',
})
const getVideos = () => {
import React, { Component } from 'react'
import { Video } from 'expo'
import VideoPlayer from '@expo/videoplayer'
import { Actions } from 'react-native-router-flux'
import api from '../../services/FixtureApi'
import Spinner from '../Spinner'
interface Props {
id: string
}
import React from 'react'
import { Scene, Router } from 'react-native-router-flux'
import Home from './views/Home'
import VideoPlayer from './views/VideoPlayer'
const AppRouter = () => (
<Router>
<Scene key="root" hideNavBar>
<Scene key="Home" component={Home} initial />
<Scene key="VideoPlayer" component={VideoPlayer} hideNavBar={true} />
getVideo: videoId => {
return {
ok: true,
data: require('../fixtures/Video.json')
}
}
{
"id": "c1r342c2",
"name": "Sea trip",
"uri": "https://www.videvo.net/videvo_files/converted/2016_11/videos/GOPR6239_1.mov34724.mp4",
"nextVideoId": "c1r342c2"
}