This file contains 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
// I use generators a lot with python. It seems elegant to me; keep only the data you need and iterate along. | |
// I was happy to see that they had added generators to JavaScript and had an example where I needed the next 30 days. | |
// I could put it in an array, but why not try using generators? | |
// After trial and error, I realized it isn't quite possible in Angular | |
// Attempt #1: Use Generator function directly in ngFor. | |
static *next30DaysPlainGenerator = function*(){ | |
const initial_date = new Date(); |
This file contains 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
public class ZenkakuHankaku{ | |
/* The character list retrieved from a JavaScript library, can't find now though. :/ */ | |
public static String toZenkaku(String s) { | |
if (String.isBlank(s)){ | |
return s; | |
} | |
String str = s.replace('\u0020', '\u3000').replace('\u0022', '\u201D').replace('\u0027', '\u2019').replace('\u00A5', '\uFFE5').replace('\uff61', '\u3002').replace('\uff62', '\u300c').replace('\uff63', '\u300d').replace('\uff64', '\u3001').replace('\uff65', '\u30fb').replace('\uff66', '\u30f2').replace('\uff67', '\u30a1').replace('\uff68', '\u30a3').replace('\uff69', '\u30a5').replace('\uff6a', '\u30a7').replace('\uff6b', '\u30a9').replace('\uff6c', '\u30e3').replace('\uff6d', '\u30e5').replace('\uff6e', '\u30e7').replace('\uff6f', '\u30c3').replace('\uff70', '\u30fc').replace('\uff71', '\u30a2').replace('\uff72', '\u30a4').replace('\uff73', '\u30a6').replace('\uff74', '\u30a8').replace('\uff75', '\u30aa').replace('\uff76', '\u30ab').replace('\uff77', '\u30ad').replace('\uff78 |
This file contains 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
package main | |
import ( | |
"fmt" | |
"os" | |
"github.com/urfave/cli" | |
) | |
func main() { |
This file contains 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
# Creating a debugger on Mac OS using Python and Python CTypes | |
# ------------------------------------------------------------ | |
# If you are like me, you are following along the Grey Hat Python book that was on the "Humble Bundle" sale and are | |
# a bit frustrated that everything is about Windows. Also that it requires Python 2.5. | |
# | |
# (I haven't used a Windows machine for years and doubt I will be doing dev for it in my career.) | |
# | |
# I am trying to implement the Chapter 3 debugger stuff in this file, using Python 3.5. | |
# This is not necessarily something pythonic or using best practices, I just want to get it working, after which | |
# I may clean it up. |
This file contains 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
// original | |
public List<selectOption> getSubCategoryEstimate(){ | |
List<selectOption> options = new List<selectOption>(); | |
if(selectedCategory!=null){ | |
List<Material_Grouping_Estimate__c> listSub = new List<Material_Grouping_Estimate__c>(); | |
listSub = [select Category__c , Sub_Category__c from Material_Grouping_Estimate__c WHERE Category__c like :selectedCategory ORDER BY Sub_Category__c]; | |
This file contains 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
// Salesforce attracts programmers that have spent too much time using the same languages | |
// their whole life, without appropriate 'adventures' into other languages. It shows sometimes. | |
// IMO APEX doesn't really go out of its way to advertise its various collection types like Python | |
// or scripting languages & functional languages do. As a result, you end up reinventing the wheel a lot. | |
// Wrong way, don't do this. | |
List<Id> LstParentId = new List<Id>(); | |
if (newList != null) |
This file contains 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 base64 | |
import os | |
import tempfile | |
from django.core.exceptions import SuspiciousFileOperation | |
from django.core.files import File | |
from django.utils._os import safe_join | |
import requests | |
from django.core.files.storage import Storage |
This file contains 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
/* | |
TODO: | |
- Handle 404s / other errors | |
- Handle invalid Attachment ids | |
- | |
*/ | |
class testUploadAttachment { | |
@future(callout=true) |
This file contains 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 Cocoa | |
// Load data from a URL. | |
let url: NSURL = NSURL(string: "http://www.tokyomuslim.com") | |
let resultsData = NSData(contentsOfURL: url, options: NSDataReadingOptions.DataReadingUncached, error: nil) | |
let resultsString:NSString = NSString(data: resultsData, encoding: NSUTF8StringEncoding) | |
// Load JSON data. | |
let jsonUrl: NSURL = NSURL(string: "https://api.github.com/users/mralexgray/repos/") | |
let jsonResultsData = NSData(contentsOfURL: jsonUrl, options: NSDataReadingOptions.DataReadingUncached, error: nil) |
This file contains 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
#! /bin/bash | |
# Wait for a CD to be inserted then copy the contents | |
# | |
echo "CD copy, press <ctrl>C to exit" | |
echo "Looking for disk..." | |
# | |
# Go into a continuous loop always looking for a new CD | |
while : | |
do |
NewerOlder