This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| ini_set('display_errors', 1); | |
| error_reporting(E_ALL); | |
| use Paytrail\SDK\Client; | |
| use Paytrail\SDK\Exception\HmacException; | |
| use Paytrail\SDK\Exception\ValidationException; | |
| use Paytrail\SDK\Model\Address; | |
| use Paytrail\SDK\Model\CallbackUrl; | |
| use Paytrail\SDK\Model\Customer; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using Microsoft.Data.Sqlite; | |
| using Microsoft.EntityFrameworkCore; | |
| using SQLitePCL; | |
| static public class Thing { | |
| public static void ListenSqlite(DbContext context) | |
| { | |
| context.Database.OpenConnection(); | |
| var c = context.Database.GetDbConnection() as SqliteConnection; | |
| SQLitePCL.raw.sqlite3_update_hook(c.Handle, test_func, new object()); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| // Disable article images that come from the content e.g. first <img /> tag | |
| add_filter('the_seo_framework_image_generation_params', function( $params, $args, $context ) { | |
| if (isset( $params['cbs']['content'])) { | |
| unset($params["cbs"]["content"]); | |
| } | |
| return $params; | |
| }, 11, 3); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // steps(10) == [0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0] == length = 11 | |
| const steps = (r) => Array(r + 1).fill().map((_, i) => i / r); // with fill | |
| const steps = (r) => ([...Array(r + 1)]).map((_, i) => i / r); // with splat | |
| const steps = (r) => Array.apply(null, Array(r + 1)).map((_, i) => i / r); // If no splat | |
| // Benchmark notes: third implementation fails with maximum stack size, first one is the fastest (with fill) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Get offset relative to selector (or window) | |
| * | |
| * @param {HTMLElement} el | |
| * @param {string|undefined} selector if not give, assumes root most (window) | |
| */ | |
| function offsetRelativeTo(el, selector) { | |
| let offsetTop = el.offsetTop; | |
| let offsetLeft = el.offsetLeft; | |
| let offsetParent = el.offsetParent; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // LICENSE MIT, Jari Pennanen | |
| // For all purposes, I also consider this public domain work. | |
| import { untrack } from "solid-js"; | |
| import { createStore } from "solid-js/store"; | |
| /** | |
| * Solid JS | |
| * | |
| * @returns Map like observable |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { createSignal, createComputed } from "solid-js"; | |
| function createProperty<T, O>(o: O, n: keyof O, def: T) { | |
| const [get, set] = createSignal(def); | |
| Object.defineProperty(o, n, { | |
| get, | |
| set, | |
| }); | |
| return def; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #[repr(C)] | |
| struct Foo(f32, f32, f32); | |
| fn main() { | |
| let a = [Foo(1.0,2.0,3.0), Foo(4.0,5.0,6.0)]; | |
| let b = [1.0f32,2.0,3.0,4.0,5.0,6.0]; | |
| let c = [(1.0f32,2.0f32,3.0f32), (4.0f32,5.0f32,6.0f32)]; | |
| let amem = unsafe { std::slice::from_raw_parts((&a as *const _) as *const u8, std::mem::size_of_val(&a) )}; | |
| let bmem = unsafe { std::slice::from_raw_parts((&b as *const _) as *const u8, std::mem::size_of_val(&b) )}; | |
| let cmem = unsafe { std::slice::from_raw_parts((&c as *const _) as *const u8, std::mem::size_of_val(&c) )}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| use std::io::Write; | |
| use std::{env, path::Path}; | |
| use std::{fs::OpenOptions, path::PathBuf}; | |
| use regex::Regex; | |
| fn main() { | |
| let dir = Path::new(&env::var("CARGO_MANIFEST_DIR").unwrap()).join("lib"); | |
| println!("cargo:rustc-link-search=native={}", dir.display()); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //! Convenience wrappers for Direct2D objects. | |
| //! | |
| //! These also function as safety boundaries (though determining the | |
| //! exact safety guarantees is work in progress). | |
| // TODO: get rid of this when we actually do use everything | |
| #![allow(unused)] | |
| use std::ffi::c_void; | |
| use std::fmt::{Debug, Display, Formatter}; |