Skip to content

Instantly share code, notes, and snippets.

@thevisioner
thevisioner / .env.local.example
Created March 7, 2023 18:42
User Authentication in Next.js with Auth.js and Strapi
GOOGLE_OAUTH_CLIENT_ID=
GOOGLE_OAUTH_CLIENT_SECRET=
NEXTAUTH_SECRET=
# Use 127.0.0.1 instead of localhost to avoid issues with NextAuth.js
NEXTAUTH_URL=http://127.0.0.1:3000
STRAPI_BACKEND_URL=http://127.0.0.1:1337
@rrosiek
rrosiek / install_mysql.sh
Last active June 5, 2023 07:08
Vagrant provision script for php, Apache, MySQL, phpMyAdmin, Laravel, and javascript helpers. Tested with Ubuntu 16.04.
#! /usr/bin/env bash
###
#
# install_mysql.sh
#
# This script assumes your Vagrantfile has been configured to map the root of
# your application to /vagrant and that your web root is the "public" folder
# (Laravel standard). Standard and error output is sent to
# /vagrant/vm_build.log during provisioning.
@DevinWalker
DevinWalker / woocommerce-optimize-scripts.php
Last active January 8, 2024 13:24
Only load WooCommerce scripts on shop pages and checkout + cart
/**
* Optimize WooCommerce Scripts
* Remove WooCommerce Generator tag, styles, and scripts from non WooCommerce pages.
*/
add_action( 'wp_enqueue_scripts', 'child_manage_woocommerce_styles', 99 );
function child_manage_woocommerce_styles() {
//remove generator meta tag
remove_action( 'wp_head', array( $GLOBALS['woocommerce'], 'generator' ) );
<?php
with(new Page())->makeRoot();
with(new Page())->makePreviousSiblingOf(Page::find(1))
with(new Page())->makeNextSiblingOf(Page::find(1))
with(new Page())->makeLastChildOf(Page::find(5))
with(new Page())->makeFirstChildOf(Page::find(2))
Page::find(2)->children()
Page::find(2)->parent()
Page::find(2)->sibling()
Page::find(2)->isDescendant(Page::find(3))
@cmsx
cmsx / VideoThumb.php
Last active February 27, 2024 16:38
Класс для получения превью и информации о ролике RuTube, Vimeo, Youtube по ссылке.
<?php
/**
* Использование:
* $v = new VideoThumb($link);
* $v->getVideo(); //Ссылка на видео
* $v->getTitle(); //Название ролика
* $v->fetchImage($path) //Скачать самое большое превью ролика
*
* Прогнать тест:
@twasink
twasink / ControllerTestSpikeSpec.js
Created November 14, 2012 03:01
An example of testing an ExtJS controller and View together. (Not shown - the creation of the ExtJs application itself, or the Jasmine setup)
Ext.define('App.controller.SpikeController', {
extend: 'Ext.app.Controller',
refs: [
{ ref: 'foobar', selector: '#foobar' },
{ ref: 'bazbux', selector: '#bazbux' },
{ ref: 'spikeView', selector: 'spike_view' }
],
init: function() {
@sgmurphy
sgmurphy / url_slug.php
Created July 12, 2012 15:52
URL Slugs in PHP (with UTF-8 and Transliteration Support)
<?php
/**
* Create a web friendly URL slug from a string.
*
* Although supported, transliteration is discouraged because
* 1) most web browsers support UTF-8 characters in URLs
* 2) transliteration causes a loss of information
*
* @author Sean Murphy <sean@iamseanmurphy.com>
* @copyright Copyright 2012 Sean Murphy. All rights reserved.
@dz0ny
dz0ny / 99java
Created July 7, 2012 10:23
Install java,flash,mp3,mp4 to Chromium OS
## Setup java
if [ `uname -m` == 'x86_64' ]; then
PATH="/usr/lib64/jvm/java-7-oracle/jre/bin/"
JAVA_HOME="/usr/lib64/jvm/java-7-oracle/"
else
PATH="/usr/lib/jvm/java-7-oracle/jre/bin/"
JAVA_HOME="/usr/lib/jvm/java-7-oracle/"
fi
@tqc
tqc / rgbatorgb.js
Created May 1, 2012 01:39
Convert RGBA to RGB
function RGBAtoRGB(r, g, b, a, r2,g2,b2){
var r3 = Math.round(((1 - a) * r2) + (a * r))
var g3 = Math.round(((1 - a) * g2) + (a * g))
var b3 = Math.round(((1 - a) * b2) + (a * b))
return "rgb("+r3+","+g3+","+b3+")";
}
$("#result").html(RGBAtoRGB(225,110,0,0.5,255,255,255));