Skip to content

Instantly share code, notes, and snippets.

View yamen's full-sized avatar

Yamen Sader yamen

  • Sydney, Australia
View GitHub Profile
@Henry-E
Henry-E / proxy_transfer.rs
Last active May 4, 2022 00:13
Very hacky PCA CPI
pub fn proxy_transfer(ctx: Context<ProxyTransfer>, amount: u64, nonce: u8) -> ProgramResult {
token::transfer(ctx.accounts.into(), amount)?;
// let seeds = &[TEST_SEED.as_bytes(), &[nonce]];
let seeds: &[&[u8]] = &[ctx.accounts.authority.to_account_info().key.as_ref(), &[nonce]];
let signer = &[&seeds[..]];
// let cpi_ctx = CpiContext::from(&*ctx.accounts).with_signer(signer);
let cpi_ctx = CpiContext::new_with_signer(
ctx.accounts.token_program.clone(),
@fphilipe
fphilipe / exclude.sql
Last active April 25, 2024 23:17
PostgreSQL EXCLUDE constraint
CREATE EXTENSION btree_gist;
CREATE TABLE room_reservations (
room_id integer,
reserved_at timestamptz,
reserved_until timestamptz,
canceled boolean DEFAULT false,
EXCLUDE USING gist (
room_id WITH =, tstzrange(reserved_at, reserved_until) WITH &&
) WHERE (not canceled)
/*jshint devel: true, node: true*/
/**
* Start an embedded Node-Red instance
*/
var http = require('http'),
express = require("express"),
path = require("path"),
_ = require("lodash"),
@pintowar
pintowar / RXGlue.groovy
Created January 14, 2015 00:56
Creating a SSE streaming with Apache Camel and Ratpack, using Rx Groovy as a glue
@Grab('com.netflix.rxjava:rxjava-groovy:0.20.7')
@Grab('io.reactivex:rxjava-reactive-streams:0.3.0')
@Grab('org.apache.camel:camel-rx:2.14.1')
@Grab('io.ratpack:ratpack-groovy:0.9.11')
@Grab('org.slf4j:slf4j-simple:1.6.6')
import org.apache.camel.impl.*
import org.apache.camel.rx.*
import static rx.RxReactiveStreams.toPublisher
import static ratpack.groovy.Groovy.ratpack
import static ratpack.sse.ServerSentEvents.serverSentEvents;
@dalcib
dalcib / ng-schema.js
Created July 25, 2012 03:38
AngularJS directive to convert JSON-Scheme in a form
/* https://github.com/nikos/cmskern/blob/master/playapp/public/javascripts/widgets.js*/
/**
* Widget for displaying a complete form as specified by the given schema.
*/
angular.widget('my:form', function(element) {
this.descend(true); // compiler will process children elements
this.directives(true); // compiler will process directives
@jpbougie
jpbougie / gist:1827065
Created February 14, 2012 14:22
Example of a SOAP request with Finagle
import java.net.InetSocketAddress
import scala.xml.{Elem, XML}
import org.jboss.netty.buffer.ChannelBuffers
import org.jboss.netty.util.CharsetUtil.UTF_8
import com.twitter.finagle.Service;
import com.twitter.finagle.builder.ClientBuilder;
import com.twitter.finagle.http.{Http, RequestBuilder};
import org.jboss.netty.handler.codec.http._
import org.jboss.netty.buffer.ChannelBuffers.wrappedBuffer
import java.net.URL