Skip to content

Instantly share code, notes, and snippets.

View micalexander's full-sized avatar

Michael Alexander micalexander

View GitHub Profile
@micalexander
micalexander / Nextjs.md
Last active May 20, 2022 22:09
Nextjs config file for loading css modules from node_modules folder

Objective get bit components to play nice with next js

Dependencies

  • npx create-next-app@latest or with typescript npx create-next-app@latest --ts
  • yarn add sass
  • yarn add next-transpile-modules

Problem?

  1. I was unable to import bit.cloud modules into next.js
var url = "https://cdnjs.cloudflare.com/ajax/libs/Swiper/3.4.2/js/swiper.min.js";
function require( url ) {
var ajax = new XMLHttpRequest();
ajax.open( 'GET', url, false ); // <-- the 'false' makes it synchronous
ajax.onreadystatechange = function () {
var script = ajax.response || ajax.responseText;
if (ajax.readyState === 4) {
switch( ajax.status) {
@micalexander
micalexander / README.md
Last active December 6, 2016 02:47
Install CA SSL on Ubuntu and Apache Server

CA SSL on an Ubuntu server running Apache

Step 1

Generate the key and csr file on the server

$ openssl req -new -newkey rsa:2048 -nodes -sha256 -days 365 -keyout domain.com.key -out domain.com.csr

Step 2

@micalexander
micalexander / README.md
Last active November 16, 2016 03:42
Turn a string of characters into a lowercased hyphenated string

Stringify

Turn a string of characters into a lowercased hyphenated string

@micalexander
micalexander / README.md
Last active November 16, 2016 03:45
PHP: Get events from google calendar

Google Calendar SDK Example

Get events from google calendar

@micalexander
micalexander / last_modified_file.rb
Created July 20, 2015 18:29
Ruby: Get last modified file from a directory
def get_last_modified(dir)
# make sure the files to be checked are in the provided directory
files = Dir.new(dir).select { |file| file!= '.' && file!='..' }
# make sure the file has been written to
return nil if (files.size < 1)
# create an array of all the files
files = files.collect { |file| File.join(dir , file) }
@micalexander
micalexander / drupal_body_classes.php
Created April 22, 2015 01:17
Add body classes to Drupal
/**
* Preprocess html;
* add page-pagname classes to the body element
*/
function hook_preprocess_html(&$vars) {
$vars['attributes_array']['class'][] = $vars['classes_array'][] = 'page-' . drupal_html_class(drupal_get_title());
}
@micalexander
micalexander / youtube-vimeo-thumbnail.js
Created October 14, 2014 21:53
jquery:snippet:Get youtube or vimeo thumbnail url
function get_video_thumb(url, callback){
var id = get_video_id(url);
if (id['type'] == 'y') {
return processYouTube(id);
} else if (id['type'] == 'v') {
$.ajax({
url: 'http://vimeo.com/api/v2/video/' + id['id'] + '.json',
dataType: 'jsonp',
success: function(data) {
@micalexander
micalexander / fancybox.css
Created June 11, 2014 04:42
fancybox:overide:css
/* -------------------------------------------------
** FANCYBOX CLEANUP & OVERIDES
** ---------------------------------------------- */
.fancybox-overlay, .fancybox-overlay *, #fancybox-thumbs, #fancybox-thumbs * {
@include box-sizing('content-box');
}
.fancybox-wrap, .fancybox-wrap * {
@include box-sizing('content-box');
@micalexander
micalexander / publish-date-accordion.php
Created June 11, 2014 02:26
wordpress:publish-date-accordion:snippet
<?php
global $post;
$post_backup = $post;
$args = array(
'posts_per_page' => -1,
'post_type' => 'post-type-news',
'orderby' => 'date',
'order' => 'DSC'
);