Skip to content

Instantly share code, notes, and snippets.

Ayesh Karunaratne Ayesh

Block or report user

Report or block Ayesh

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View keybase.md

Keybase proof

I hereby claim:

  • I am ayesh on github.
  • I am ayesh (https://keybase.io/ayesh) on keybase.
  • I have a public key ASDeCBZ3Gd198xEnKmcpHKk4ZrsHxyRXkzoKqT-HyDqGsAo

To claim this, I am signing this object:

View gist:19c8dc55acd4ff511904dfb0d0bc6033
### Keybase proof
I hereby claim:
* I am Ayesh on github.
* I am ayesh (https://keybase.io/ayesh) on keybase.
* I have a public key whose fingerprint is 1083 D261 72E3 855D 4F0A A4D6 0A85 2BB5 2939 C224
To claim this, I am signing this object:
@Ayesh
Ayesh / SCSS.md
Created Jul 13, 2017 — forked from jareware/SCSS.md
Advanced SCSS, or, 16 cool things you may not have known your stylesheets could do
View SCSS.md

⇐ back to the gist-blog at jrw.fi

Advanced SCSS

Or, 16 cool things you may not have known your stylesheets could do. I'd rather have kept it to a nice round number like 10, but they just kept coming. Sorry.

I've been using SCSS/SASS for most of my styling work since 2009, and I'm a huge fan of Compass (by the great @chriseppstein). It really helped many of us through the darkest cross-browser crap. Even though browsers are increasingly playing nice with CSS, another problem has become very topical: managing the complexity in stylesheets as our in-browser apps get larger and larger. SCSS is an indispensable tool for dealing with this.

This isn't an introduction to the language by a long shot; many things probably won't make sense unless you have some SCSS under your belt already. That said, if you're not yet comfy with the basics, check out the aweso

View CAA-adoption-notes.md
View core_user_add_searched_account.patch
diff --git a/modules/user/user.module b/modules/user/user.module
index 9637a71..7426bbe 100644
--- a/modules/user/user.module
+++ b/modules/user/user.module
@@ -985,6 +985,7 @@ function user_search_execute($keys = NULL, $conditions = NULL) {
$results = array();
foreach ($accounts as $account) {
$result = array(
+ 'account' => $account,
'title' => format_username($account),
@Ayesh
Ayesh / Drupal 7 programtic user login
Created Apr 23, 2015
Drupal login user programatically.
View Drupal 7 programtic user login
<?php
/**
* @param $uid The user ID to log in.
* @return bool Whether the user was logged in or not.
*/
function CUSTOM_user_programatic_login($uid) {
global $user;
$user = user_load($_GET['uid']);
if ($user) {
$form_state = array();
@Ayesh
Ayesh / gist:e949642860a01c350b29
Created Mar 14, 2015
Generate an array of random integers that averages (or closes) to a given float or integer
View gist:e949642860a01c350b29
<?php
function getRandomintegersFloatAvg($target, $count, $min = 1, $max = 5, $precision = 2) {
if ($target > $max) return FALSE;
if ($target < $min) return FALSE;
if ($count < 1) return FALSE;
if ($count === 1) return array(round($target));
$values = array();
for ($i = 0; $i < $count; $i++) {
$values[] = mt_rand($min, $max);
View gist:6f41cdf7ad135f2836b0
<?php
/**
* Define a new Node class, that has a create static
* method to create an instance of the current class (Node,
* or the overriden class name). Then, copy the feeded
* node object's properties to the newly created object.
*/
class Node {
static public function create(stdClass $node = NULL) {
You can’t perform that action at this time.