Skip to content

Instantly share code, notes, and snippets.

View raphox's full-sized avatar

Raphael Araújo raphox

View GitHub Profile
@raphox
raphox / jsonb_to_table_row.sql
Created August 3, 2022 19:06
copy jsonb data to table row
select agreement_uuid, term->'uuid' from new_agreements
CROSS JOIN LATERAL jsonb_array_elements(royalties_terms) term
where id = 26
create type royalties_terms as (uuid text);
select term.*, agreement_uuid as new_agreement_uuid from new_agreements
CROSS JOIN LATERAL jsonb_populate_recordset(null::agreements_royalty_terms, royalties_terms) term
where id = 26
@raphox
raphox / obfuscate-phone-number.js
Created June 8, 2021 11:34
obfuscate phone number
'+5533991998109'.replace(/[\S](?=[\w]{4})/g, 'X');
@raphox
raphox / whatsapp-console.js
Last active June 1, 2021 13:21
whatsapp-console.js
/* moduleRaid v5 - https://github.com/@pedroslopez/moduleRaid */
const moduleRaid=function(){return moduleRaid.mID=Math.random().toString(36).substring(7),moduleRaid.mObj={},fillModuleArray=function(){webpackChunkbuild.push([[moduleRaid.mID],{},function(o){Object.keys(o.m).forEach(function(e){moduleRaid.mObj[e]=o(e)})}])},fillModuleArray(),get=function(o){return moduleRaid.mObj[o]},findModule=function(o){return results=[],modules=Object.keys(moduleRaid.mObj),modules.forEach(function(e){if(mod=moduleRaid.mObj[e],"undefined"!=typeof mod)if("string"==typeof o){if("object"==typeof mod.default)for(key in mod.default)key==o&&results.push(mod);for(key in mod)key==o&&results.push(mod)}else{if("function"!=typeof o)throw new TypeError("findModule can only find via string and function, "+typeof o+" was passed");o(mod)&&results.push(mod)}}),results},{modules:moduleRaid.mObj,constructors:moduleRaid.cArr,findModule:findModule,get:get}};
window.mR = moduleRaid();
window.Store = window.mR.findModule('Chat')[0].default;
win
// firebase-messaging-sw.js
importScripts("https://www.gstatic.com/firebasejs/8.2.6/firebase-app.js");
importScripts("https://www.gstatic.com/firebasejs/8.2.6/firebase-messaging.js");
self.addEventListener("notificationclick", function (event) {
var redirectUrl = event.notification.data.FCM_MSG.notification.click_action;
event.waitUntil(
self.clients
def friends_by_search(term)
friends_path = {}
friends = as(:user).friends(:l, :r, rel_length: { max: 5 }).
where('ANY(title IN l.titles WHERE toLower(title) CONTAINS toLower({title})) OR
ANY(subtitle IN l.subtitles WHERE toLower(subtitle) CONTAINS toLower({title}))').
where('l <> user').
params({ title: term }).
to_a
class UserNeo4j
include Neo4j::ActiveNode
include Neo4j::Timestamps
property :slug
property :first_name
property :last_name
property :website
property :titles
property :subtitles
CREATE OR REPLACE FUNCTION notify_rows_changes()
RETURNS trigger AS $$
DECLARE
record JSON;
BEGIN
record := row_to_json(CASE TG_OP
WHEN 'INSERT' THEN NEW
WHEN 'UPDATE' THEN NEW
ELSE OLD
END);
// ...
// Create an http link:
const httpLink = new HttpLink({
uri: "http://localhost:4000/graphql",
});
// Create a WebSocket link:
const wsLink = new WebSocketLink({
uri: `ws://localhost:4000/graphql`,
// ...
const ROOMS_SUBSCRIPTION = gql`
subscription {
roomUpdatedOrDelete {
operation
record {
id
number
description
require("dotenv").config();
const { ApolloServer, gql } = require("apollo-server");
const { createStore } = require("./utils");
const { merge } = require("lodash");
const RoomAPI = require("./datasources/room");
const { typeDef: Room, resolvers: roomResolvers } = require("./schemas/room");